Skip to content

Commit

Permalink
Nullability fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaben committed Sep 20, 2024
1 parent 2586ecd commit 2359cef
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 78 deletions.
52 changes: 26 additions & 26 deletions src/SerilogCommonLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public virtual void Trace(object message, Exception exception)
Write(LogLevel.Trace, exception, message);
}

public virtual void TraceFormat(IFormatProvider formatProvider, string format, params object[] args)
public virtual void TraceFormat(IFormatProvider? formatProvider, string format, params object[] args)
{
if (!IsTraceEnabled)
return;

WriteFormat(LogLevel.Trace, formatProvider, format, args);
}

public virtual void TraceFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
public virtual void TraceFormat(IFormatProvider? formatProvider, string format, Exception? exception, params object[] args)
{
if (!IsTraceEnabled)
return;
Expand All @@ -83,7 +83,7 @@ public virtual void TraceFormat(string format, params object[] args)
WriteFormat(LogLevel.Trace, format, args);
}

public virtual void TraceFormat(string format, Exception exception, params object[] args)
public virtual void TraceFormat(string format, Exception? exception, params object[] args)
{
if (!IsTraceEnabled)
return;
Expand Down Expand Up @@ -139,15 +139,15 @@ public virtual void Debug(object message, Exception exception)
Write(LogLevel.Debug, exception, message);
}

public virtual void DebugFormat(IFormatProvider formatProvider, string format, params object[] args)
public virtual void DebugFormat(IFormatProvider? formatProvider, string format, params object[] args)
{
if (!IsDebugEnabled)
return;

WriteFormat(LogLevel.Debug, formatProvider, format, args);
}

public virtual void DebugFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
public virtual void DebugFormat(IFormatProvider? formatProvider, string format, Exception? exception, params object[] args)
{
if (!IsDebugEnabled)
return;
Expand All @@ -163,7 +163,7 @@ public virtual void DebugFormat(string format, params object[] args)
WriteFormat(LogLevel.Debug, format, args);
}

public virtual void DebugFormat(string format, Exception exception, params object[] args)
public virtual void DebugFormat(string format, Exception? exception, params object[] args)
{
if (!IsDebugEnabled)
return;
Expand Down Expand Up @@ -219,15 +219,15 @@ public virtual void Info(object message, Exception exception)
Write(LogLevel.Info, exception, message);
}

public virtual void InfoFormat(IFormatProvider formatProvider, string format, params object[] args)
public virtual void InfoFormat(IFormatProvider? formatProvider, string format, params object[] args)
{
if (!IsInfoEnabled)
return;

WriteFormat(LogLevel.Info, formatProvider, format, args);
}

public virtual void InfoFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
public virtual void InfoFormat(IFormatProvider? formatProvider, string format, Exception? exception, params object[] args)
{
if (!IsInfoEnabled)
return;
Expand All @@ -243,7 +243,7 @@ public virtual void InfoFormat(string format, params object[] args)
WriteFormat(LogLevel.Info, format, args);
}

public virtual void InfoFormat(string format, Exception exception, params object[] args)
public virtual void InfoFormat(string format, Exception? exception, params object[] args)
{
if (!IsInfoEnabled)
return;
Expand Down Expand Up @@ -299,15 +299,15 @@ public virtual void Warn(object message, Exception exception)
Write(LogLevel.Warn, exception, message);
}

public virtual void WarnFormat(IFormatProvider formatProvider, string format, params object[] args)
public virtual void WarnFormat(IFormatProvider? formatProvider, string format, params object[] args)
{
if (!IsWarnEnabled)
return;

WriteFormat(LogLevel.Warn, formatProvider, format, args);
}

public virtual void WarnFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
public virtual void WarnFormat(IFormatProvider? formatProvider, string format, Exception? exception, params object[] args)
{
if (!IsWarnEnabled)
return;
Expand All @@ -323,7 +323,7 @@ public virtual void WarnFormat(string format, params object[] args)
WriteFormat(LogLevel.Warn, format, args);
}

public virtual void WarnFormat(string format, Exception exception, params object[] args)
public virtual void WarnFormat(string format, Exception? exception, params object[] args)
{
if (!IsWarnEnabled)
return;
Expand Down Expand Up @@ -379,15 +379,15 @@ public virtual void Error(object message, Exception exception)
Write(LogLevel.Error, exception, message);
}

public virtual void ErrorFormat(IFormatProvider formatProvider, string format, params object[] args)
public virtual void ErrorFormat(IFormatProvider? formatProvider, string format, params object[] args)
{
if (!IsErrorEnabled)
return;

WriteFormat(LogLevel.Error, formatProvider, format, args);
}

public virtual void ErrorFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
public virtual void ErrorFormat(IFormatProvider? formatProvider, string format, Exception? exception, params object[] args)
{
if (!IsErrorEnabled)
return;
Expand All @@ -403,7 +403,7 @@ public virtual void ErrorFormat(string format, params object[] args)
WriteFormat(LogLevel.Error, format, args);
}

public virtual void ErrorFormat(string format, Exception exception, params object[] args)
public virtual void ErrorFormat(string format, Exception? exception, params object[] args)
{
if (!IsErrorEnabled)
return;
Expand Down Expand Up @@ -459,15 +459,15 @@ public virtual void Fatal(object message, Exception exception)
Write(LogLevel.Fatal, exception, message);
}

public virtual void FatalFormat(IFormatProvider formatProvider, string format, params object[] args)
public virtual void FatalFormat(IFormatProvider? formatProvider, string format, params object[] args)
{
if (!IsFatalEnabled)
return;

WriteFormat(LogLevel.Fatal, formatProvider, format, args);
}

public virtual void FatalFormat(IFormatProvider formatProvider, string format, Exception exception, params object[] args)
public virtual void FatalFormat(IFormatProvider? formatProvider, string format, Exception? exception, params object[] args)
{
if (!IsFatalEnabled)
return;
Expand All @@ -483,7 +483,7 @@ public virtual void FatalFormat(string format, params object[] args)
WriteFormat(LogLevel.Fatal, format, args);
}

public virtual void FatalFormat(string format, Exception exception, params object[] args)
public virtual void FatalFormat(string format, Exception? exception, params object[] args)
{
if (!IsFatalEnabled)
return;
Expand Down Expand Up @@ -543,29 +543,29 @@ protected void Write(LogLevel level, object message)
Write(level, null, message);
}

protected void Write(LogLevel level, Exception exception, object message)
protected void Write(LogLevel level, Exception? exception, object message)
{
if (message is string)
_logger.Write(level.ToSerilogEventLevel(), exception, "{Message:l}", message.ToString());
else
_logger.Write(level.ToSerilogEventLevel(), exception, "{@Message}", message);
}

protected void WriteCallback(LogLevel level, Action<FormatMessageHandler> formatMessageCallback, Exception exception = null)
protected void WriteCallback(LogLevel level, Action<FormatMessageHandler> formatMessageCallback, Exception? exception = null)
{
WriteCallback(level, null, formatMessageCallback, exception);
}

protected void WriteCallback(
LogLevel level,
IFormatProvider formatProvider,
IFormatProvider? formatProvider,
Action<FormatMessageHandler> formatMessageCallback,
Exception exception = null)
Exception? exception = null)
{
formatMessageCallback(MakeFormatted(level, formatProvider, exception));
}

protected FormatMessageHandler MakeFormatted(LogLevel level, IFormatProvider formatProvider, Exception exception)
protected FormatMessageHandler MakeFormatted(LogLevel level, IFormatProvider? formatProvider, Exception? exception)
{
var messageHandler = new FormatMessageHandler(
delegate(string message, object[] parameters)
Expand All @@ -588,12 +588,12 @@ protected FormatMessageHandler MakeFormatted(LogLevel level, IFormatProvider for
return messageHandler;
}

protected void WriteFormat(LogLevel level, Exception exception, string message, object[] parameters)
protected void WriteFormat(LogLevel level, Exception? exception, string message, object[] parameters)
{
WriteFormat(level, exception, null, message, parameters);
}

protected void WriteFormat(LogLevel level, IFormatProvider formatProvider, string message, object[] parameters)
protected void WriteFormat(LogLevel level, IFormatProvider? formatProvider, string message, object[] parameters)
{
WriteFormat(level, null, formatProvider, message, parameters);
}
Expand All @@ -603,7 +603,7 @@ protected void WriteFormat(LogLevel level, string message, object[] parameters)
WriteFormat(level, null, null, message, parameters);
}

protected void WriteFormat(LogLevel level, Exception exception, IFormatProvider formatProvider, string message, object[] parameters)
protected void WriteFormat(LogLevel level, Exception? exception, IFormatProvider? formatProvider, string message, object[] parameters)
{
if (formatProvider == null)
{
Expand Down
Loading

0 comments on commit 2359cef

Please sign in to comment.