diff options
author | Jan Tattermusch <jtattermusch@google.com> | 2015-09-17 19:34:31 -0700 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@google.com> | 2015-09-17 19:36:53 -0700 |
commit | c4ebda7d304e48ca628e3757161db76e9636d997 (patch) | |
tree | 97136495939603718858bb229b62f88f6d9502c4 | |
parent | 1965810ede1dae0aaf72d55e1359e640d08720f8 (diff) |
plain log message should not be treated as format string
-rw-r--r-- | src/csharp/Grpc.Core/Logging/ConsoleLogger.cs | 52 | ||||
-rw-r--r-- | src/csharp/Grpc.Core/Logging/ILogger.cs | 24 |
2 files changed, 56 insertions, 20 deletions
diff --git a/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs b/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs index 35561d25d8..5c5b802164 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 } /// <summary>Logs a message with severity Debug.</summary> - public void Debug(string message, params object[] formatArgs) + public void Debug(string message) { - Log("D", message, formatArgs); + Log("D", message); + } + + /// <summary>Logs a formatted message with severity Debug.</summary> + public void Debug(string format, params object[] formatArgs) + { + Debug(string.Format(format, formatArgs)); } /// <summary>Logs a message with severity Info.</summary> - public void Info(string message, params object[] formatArgs) + public void Info(string message) + { + Log("I", message); + } + + /// <summary>Logs a formatted message with severity Info.</summary> + public void Info(string format, params object[] formatArgs) { - Log("I", message, formatArgs); + Info(string.Format(format, formatArgs)); } /// <summary>Logs a message with severity Warning.</summary> - public void Warning(string message, params object[] formatArgs) + public void Warning(string message) { - Log("W", message, formatArgs); + Log("W", message); + } + + /// <summary>Logs a formatted message with severity Warning.</summary> + public void Warning(string format, params object[] formatArgs) + { + Warning(string.Format(format, formatArgs)); } /// <summary>Logs a message and an associated exception with severity Warning.</summary> - 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); } /// <summary>Logs a message with severity Error.</summary> - public void Error(string message, params object[] formatArgs) + public void Error(string message) + { + Log("E", message); + } + + /// <summary>Logs a formatted message with severity Error.</summary> + public void Error(string format, params object[] formatArgs) { - Log("E", message, formatArgs); + Error(string.Format(format, formatArgs)); } /// <summary>Logs a message and an associated exception with severity Error.</summary> - 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 61e0c91388..7c0326422f 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<T>(); /// <summary>Logs a message with severity Debug.</summary> - void Debug(string message, params object[] formatArgs); + void Debug(string message); + + /// <summary>Logs a formatted message with severity Debug.</summary> + void Debug(string format, params object[] formatArgs); /// <summary>Logs a message with severity Info.</summary> - void Info(string message, params object[] formatArgs); + void Info(string message); + + /// <summary>Logs a formatted message with severity Info.</summary> + void Info(string format, params object[] formatArgs); /// <summary>Logs a message with severity Warning.</summary> - void Warning(string message, params object[] formatArgs); + void Warning(string message); + + /// <summary>Logs a formatted message with severity Warning.</summary> + void Warning(string format, params object[] formatArgs); /// <summary>Logs a message and an associated exception with severity Warning.</summary> - void Warning(Exception exception, string message, params object[] formatArgs); + void Warning(Exception exception, string message); /// <summary>Logs a message with severity Error.</summary> - void Error(string message, params object[] formatArgs); + void Error(string message); + + /// <summary>Logs a formatted message with severity Error.</summary> + void Error(string format, params object[] formatArgs); /// <summary>Logs a message and an associated exception with severity Error.</summary> - void Error(Exception exception, string message, params object[] formatArgs); + void Error(Exception exception, string message); } } |