Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods for semantic logging support #901

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions dotnet/src/dotnetframework/GxClasses/Diagnostics/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,60 @@ public static void Write(int logLevel, string message, string topic)
{
Write(message, topic, logLevel);
}

private static void LoggingFunc(string message, string topic, int logLevel, params string[] list)
{
IGXLogger log = GetLogger(topic);
LogLevel logLvl = (LogLevel)logLevel;

switch (logLvl)
{
case LogLevel.Off:
break;
case LogLevel.Trace:
GXLogging.Trace(log, message, list);
break;
case LogLevel.Debug:
GXLogging.Debug(log, message, list);
break;
case LogLevel.Info:
GXLogging.Info(log, message, list);
break;
case LogLevel.Warn:
GXLogging.Warn(log, message, list);
break;
case LogLevel.Error:
GXLogging.Error(log, message, list);
break;
case LogLevel.Fatal:
GXLogging.Critical(log, message, list);
break;
default:
GXLogging.Debug(log, message, list);
break;
}
}
public static void Write(string message, string topic, int logLevel, string propertyvalue1)
{
LoggingFunc(message, topic, logLevel, propertyvalue1);
}
public static void Write(string message, string topic, int logLevel, string propertyvalue1, string propertyvalue2)
{
LoggingFunc(message, topic, logLevel, propertyvalue1, propertyvalue2);
}
public static void Write(string message, string topic, int logLevel, string propertyvalue1, string propertyvalue2, string propertyvalue3)
{
LoggingFunc(message, topic, logLevel, propertyvalue1, propertyvalue2, propertyvalue3);
}
public static void Write(string message, string topic, int logLevel, string propertyvalue1, string propertyvalue2, string propertyvalue3, string propertyvalue4)
{
LoggingFunc(message, topic, logLevel, propertyvalue1, propertyvalue2, propertyvalue3, propertyvalue4);
}
public static void Write(string message, string topic, int logLevel, string propertyvalue1, string propertyvalue2, string propertyvalue3, string propertyvalue4, string propertyvalue5)
{
LoggingFunc(message, topic, logLevel, propertyvalue1, propertyvalue2, propertyvalue3, propertyvalue4, propertyvalue5);
}

public static void Write(string message, string topic, int logLevel)
{
LogLevel logLvl = (LogLevel)logLevel;
Expand Down
26 changes: 26 additions & 0 deletions dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@


void LogTrace(string value);
void LogTrace(string value, params string[] list);
void LogError(string msg, Exception ex);

void LogError(string msg);
Expand Down Expand Up @@ -119,6 +120,10 @@
{
log.LogTrace(msg);
}
public void LogTrace(string msg, params string[] list)
{
log.LogTrace(msg, list);
}
public void LogError(string msg, Exception ex)
{
log.LogError(ex, msg);
Expand Down Expand Up @@ -256,6 +261,18 @@
SetThreadIdForLogging();
log.Logger.Log(MethodBase.GetCurrentMethod().DeclaringType, Level.Trace, value, null);
}

public void LogTrace(string value, params string[] list)
{
SetThreadIdForLogging();
StringBuilder message = new StringBuilder();
message.Append(value);
foreach (string parm in list)
{
message.Append(parm);
}
log.Logger.Log(MethodBase.GetCurrentMethod().DeclaringType, Level.Trace, message.ToString(), null);
}
public void LogError(string msg, Exception ex)
{
SetThreadIdForLogging();
Expand Down Expand Up @@ -519,6 +536,14 @@
logger.LogTrace(string.Join(" ", list));
}
}
internal static void Trace(IGXLogger logger, params string[] list)

Check failure on line 539 in dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

Type 'GXLogging' already defines a member called 'Trace' with the same parameter types

Check failure on line 539 in dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

Type 'GXLogging' already defines a member called 'Trace' with the same parameter types

Check failure on line 539 in dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

Type 'GXLogging' already defines a member called 'Trace' with the same parameter types

Check failure on line 539 in dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

Type 'GXLogging' already defines a member called 'Trace' with the same parameter types

Check failure on line 539 in dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

Type 'GXLogging' already defines a member called 'Trace' with the same parameter types

Check failure on line 539 in dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

Type 'GXLogging' already defines a member called 'Trace' with the same parameter types

Check failure on line 539 in dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Type 'GXLogging' already defines a member called 'Trace' with the same parameter types

Check failure on line 539 in dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Type 'GXLogging' already defines a member called 'Trace' with the same parameter types
{
if (logger != null)
{
if (logger.IsTraceEnabled)
logger.LogTrace(string.Join(" ", list));
}
}
internal static void Trace(IGXLogger logger, Func<string> buildMsg)
{
if (logger != null)
Expand All @@ -530,6 +555,7 @@
}
}
}

internal static bool TraceEnabled(IGXLogger logger)
{
if (logger != null)
Expand Down
Loading