diff --git a/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs b/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs index 35561d25d8a..5c5b8021641 100644 --- a/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs +++ b/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs @@ -79,48 +79,72 @@ namespace Grpc.Core.Logging } /// Logs a message with severity Debug. - public void Debug(string message, params object[] formatArgs) + public void Debug(string message) { - Log("D", message, formatArgs); + Log("D", message); + } + + /// Logs a formatted message with severity Debug. + public void Debug(string format, params object[] formatArgs) + { + Debug(string.Format(format, formatArgs)); } /// Logs a message with severity Info. - public void Info(string message, params object[] formatArgs) + public void Info(string message) + { + Log("I", message); + } + + /// Logs a formatted message with severity Info. + public void Info(string format, params object[] formatArgs) { - Log("I", message, formatArgs); + Info(string.Format(format, formatArgs)); } /// Logs a message with severity Warning. - public void Warning(string message, params object[] formatArgs) + public void Warning(string message) { - Log("W", message, formatArgs); + Log("W", message); + } + + /// Logs a formatted message with severity Warning. + public void Warning(string format, params object[] formatArgs) + { + Warning(string.Format(format, formatArgs)); } /// Logs a message and an associated exception with severity Warning. - public void Warning(Exception exception, string message, params object[] formatArgs) + public void Warning(Exception exception, string message) { - Log("W", message + " " + exception, formatArgs); + Warning(message + " " + exception); } /// Logs a message with severity Error. - public void Error(string message, params object[] formatArgs) + public void Error(string message) + { + Log("E", message); + } + + /// Logs a formatted message with severity Error. + public void Error(string format, params object[] formatArgs) { - Log("E", message, formatArgs); + Error(string.Format(format, formatArgs)); } /// Logs a message and an associated exception with severity Error. - public void Error(Exception exception, string message, params object[] formatArgs) + public void Error(Exception exception, string message) { - Log("E", message + " " + exception, formatArgs); + Error(message + " " + exception); } - private void Log(string severityString, string message, object[] formatArgs) + private void Log(string severityString, string message) { Console.Error.WriteLine("{0}{1} {2}{3}", severityString, DateTime.Now, forTypeString, - string.Format(message, formatArgs)); + message); } } } diff --git a/src/csharp/Grpc.Core/Logging/ILogger.cs b/src/csharp/Grpc.Core/Logging/ILogger.cs index 61e0c91388b..7c0326422f4 100644 --- a/src/csharp/Grpc.Core/Logging/ILogger.cs +++ b/src/csharp/Grpc.Core/Logging/ILogger.cs @@ -43,21 +43,33 @@ namespace Grpc.Core.Logging ILogger ForType(); /// Logs a message with severity Debug. - void Debug(string message, params object[] formatArgs); + void Debug(string message); + + /// Logs a formatted message with severity Debug. + void Debug(string format, params object[] formatArgs); /// Logs a message with severity Info. - void Info(string message, params object[] formatArgs); + void Info(string message); + + /// Logs a formatted message with severity Info. + void Info(string format, params object[] formatArgs); /// Logs a message with severity Warning. - void Warning(string message, params object[] formatArgs); + void Warning(string message); + + /// Logs a formatted message with severity Warning. + void Warning(string format, params object[] formatArgs); /// Logs a message and an associated exception with severity Warning. - void Warning(Exception exception, string message, params object[] formatArgs); + void Warning(Exception exception, string message); /// Logs a message with severity Error. - void Error(string message, params object[] formatArgs); + void Error(string message); + + /// Logs a formatted message with severity Error. + void Error(string format, params object[] formatArgs); /// Logs a message and an associated exception with severity Error. - void Error(Exception exception, string message, params object[] formatArgs); + void Error(Exception exception, string message); } }