Skip to content

Commit 0f45739

Browse files
committed
Added LogModify to BaseStorageBusinessService, so when no model was loaded logging remains possible
1 parent f5570d6 commit 0f45739

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

MZBase.Infrastructure/MZBase.Infrastructure.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.1</TargetFramework>
55
<Nullable>enable</Nullable>
6-
<Version>2.0.5</Version>
6+
<Version>2.0.6</Version>
77
<Authors>Mahdi Zandakbari</Authors>
88
<Description>A simple library for base infrastructure interfaces of common usabilities needed in enterprise software.
99
It includes interfaces for repository, unit of work and date time providers with testing and domain-technology separation in mind</Description>

MZBase.Infrastructure/Service/BaseStorageBusinessService.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,31 @@ protected void LogModify(Model model, string? objectDescriptor = null, Exception
183183
Log(new EventId(_logBaseID + 3, "Modify"), s, model?.ID.ToString(), logType);
184184
}
185185

186+
protected void LogModify(string modelId, string? objectDescriptor = null, Exception? ex = null)
187+
{
188+
LogTypeEnum logType = LogTypeEnum.SuccessLog;
189+
string s = typeof(Model).Name + " updated";
190+
if (ex != null)
191+
{
192+
s = "Error in updating " + typeof(Model).Name;
193+
logType = LogTypeEnum.ErrorLog;
194+
}
195+
196+
if (modelId != null)
197+
{
198+
s += " ,ID:" + modelId;
199+
}
200+
if (!string.IsNullOrWhiteSpace(objectDescriptor))
201+
{
202+
s += " ," + objectDescriptor;
203+
}
204+
if (ex != null)
205+
{
206+
s += " ,exception:" + GetExceptionMessage(ex);
207+
}
208+
Log(new EventId(_logBaseID + 3, "Modify"), s, modelId, logType);
209+
}
210+
186211
/// <summary>
187212
/// Logs the removal of an entity.
188213
/// </summary>

0 commit comments

Comments
 (0)