-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from PepperDash/feature-2/fix-logError-message
Logging updates
- Loading branch information
Showing
6 changed files
with
131 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Crestron.SimplSharp; | ||
using Serilog.Core; | ||
using Serilog.Events; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace PepperDash.Core.Logging | ||
{ | ||
public class CrestronEnricher : ILogEventEnricher | ||
{ | ||
static readonly string _appName; | ||
|
||
static CrestronEnricher() | ||
{ | ||
switch (CrestronEnvironment.DevicePlatform) | ||
{ | ||
case eDevicePlatform.Appliance: | ||
_appName = $"App {InitialParametersClass.ApplicationNumber}"; | ||
break; | ||
case eDevicePlatform.Server: | ||
_appName = $"{InitialParametersClass.RoomId}"; | ||
break; | ||
} | ||
} | ||
|
||
|
||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) | ||
{ | ||
var property = propertyFactory.CreateProperty("App", _appName); | ||
|
||
logEvent.AddOrUpdateProperty(property); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Serilog; | ||
using Serilog.Events; | ||
using Log = PepperDash.Core.Debug; | ||
|
||
namespace PepperDash.Core.Logging | ||
{ | ||
public static class DebugExtensions | ||
{ | ||
public static void LogVerbose(this IKeyed device, string message, params object[] args) | ||
{ | ||
Log.LogMessage(LogEventLevel.Verbose, device, message, args); | ||
} | ||
|
||
public static void LogDebug(this IKeyed device, string message, params object[] args) | ||
{ | ||
Log.LogMessage(LogEventLevel.Debug, device, message, args); | ||
} | ||
|
||
public static void LogInformation(this IKeyed device, string message, params object[] args) | ||
{ | ||
Log.LogMessage(LogEventLevel.Information, device, message, args); | ||
} | ||
|
||
public static void LogWarning(this IKeyed device, string message, params object[] args) | ||
{ | ||
Log.LogMessage(LogEventLevel.Warning, device, message, args); | ||
} | ||
|
||
public static void LogError(this IKeyed device, string message, params object[] args) | ||
{ | ||
Log.LogMessage(LogEventLevel.Error, device, message, args); | ||
} | ||
|
||
public static void LogFatal(this IKeyed device, string message, params object[] args) | ||
{ | ||
Log.LogMessage(LogEventLevel.Fatal, device, message, args); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters