diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-03-15 20:44:10 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-03-15 20:44:10 -0700 |
commit | 493c9bbd3025f8bb2b5be0db5aa8323b14adb793 (patch) | |
tree | 204760f67afa427a1e7099036d170a67e8d73ef9 /src | |
parent | f591de83d8c41b98afaab6359622846f9b465b3a (diff) | |
download | DotNetOpenAuth-493c9bbd3025f8bb2b5be0db5aa8323b14adb793.zip DotNetOpenAuth-493c9bbd3025f8bb2b5be0db5aa8323b14adb793.tar.gz DotNetOpenAuth-493c9bbd3025f8bb2b5be0db5aa8323b14adb793.tar.bz2 |
Cleaned up logging.
Diffstat (limited to 'src')
39 files changed, 189 insertions, 983 deletions
diff --git a/src/DotNetOpenAuth.Test/Hosting/AspNetHost.cs b/src/DotNetOpenAuth.Test/Hosting/AspNetHost.cs index 3a2e97d..e4cdc9b 100644 --- a/src/DotNetOpenAuth.Test/Hosting/AspNetHost.cs +++ b/src/DotNetOpenAuth.Test/Hosting/AspNetHost.cs @@ -61,7 +61,7 @@ namespace DotNetOpenAuth.Test.Hosting { HttpRuntime.ProcessRequest(new TestingWorkerRequest(context, tw)); } } catch (Exception ex) { - Logger.Error("Exception in AspNetHost", ex); + Logger.Http.Error("Exception in AspNetHost", ex); throw; } } diff --git a/src/DotNetOpenAuth.Test/Hosting/HttpHost.cs b/src/DotNetOpenAuth.Test/Hosting/HttpHost.cs index dee1ea3..1707077 100644 --- a/src/DotNetOpenAuth.Test/Hosting/HttpHost.cs +++ b/src/DotNetOpenAuth.Test/Hosting/HttpHost.cs @@ -71,10 +71,10 @@ namespace DotNetOpenAuth.Test.Hosting { } } } catch (WebException ex) { - Logger.Error("Exception in HttpHost", ex); + Logger.Http.Error("Exception in HttpHost", ex); using (StreamReader sr = new StreamReader(ex.Response.GetResponseStream())) { string streamContent = sr.ReadToEnd(); - Logger.ErrorFormat("Error content stream follows: {0}", streamContent); + Logger.Http.ErrorFormat("Error content stream follows: {0}", streamContent); } throw; } diff --git a/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs b/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs index 51e966b..d2e1f0b 100644 --- a/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs +++ b/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs @@ -43,7 +43,7 @@ namespace DotNetOpenAuth.Test.Mocks { internal void RegisterMockResponse(IncomingWebResponse response) { ErrorUtilities.VerifyArgumentNotNull(response, "response"); if (this.registeredMockResponses.ContainsKey(response.RequestUri)) { - Logger.WarnFormat("Mock HTTP response already registered for {0}.", response.RequestUri); + Logger.Http.WarnFormat("Mock HTTP response already registered for {0}.", response.RequestUri); } else { this.registeredMockResponses.Add(response.RequestUri, response); } @@ -196,7 +196,7 @@ namespace DotNetOpenAuth.Test.Mocks { return response; } else { ////Assert.Fail("Unexpected HTTP request: {0}", uri); - Logger.WarnFormat("Unexpected HTTP request: {0}", request.RequestUri); + Logger.Http.WarnFormat("Unexpected HTTP request: {0}", request.RequestUri); return new CachedDirectWebResponse(request.RequestUri, request.RequestUri, new WebHeaderCollection(), HttpStatusCode.NotFound, "text/html", null, new MemoryStream()); } } diff --git a/src/DotNetOpenAuth/Logger.cs b/src/DotNetOpenAuth/Logger.cs index 86c7bfb..eec423b 100644 --- a/src/DotNetOpenAuth/Logger.cs +++ b/src/DotNetOpenAuth/Logger.cs @@ -8,6 +8,7 @@ namespace DotNetOpenAuth { using System; using System.Globalization; using DotNetOpenAuth.Loggers; + using DotNetOpenAuth.Messaging; using log4net.Core; /// <summary> @@ -18,898 +19,94 @@ namespace DotNetOpenAuth { /// overloads that take <see cref="CultureInfo"/> have been removed, and /// <see cref="CultureInfo.InvariantCulture"/> is used implicitly. /// </remarks> - internal static class Logger { + internal static partial class Logger { /// <summary> /// The <see cref="ILog"/> instance that is to be used /// by this static Logger for the duration of the appdomain. /// </summary> - private static ILog facade = Create("DotNetOpenAuth"); + private static readonly ILog facade = CreateWithBanner("DotNetOpenAuth"); - #region ILog Members - //// Although this static class doesn't literally implement the ILog interface, - //// we implement (mostly) all the same methods in a static way. + #region Category-specific loggers /// <summary> - /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Debug"/> level. + /// Backing field for the <see cref="Yadis"/> property. /// </summary> - /// <value> - /// <c>true</c> if this logger is enabled for <see cref="Level.Debug"/> events, <c>false</c> otherwise. - /// </value> - /// <remarks> - /// <para> - /// This function is intended to lessen the computational cost of - /// disabled log debug statements. - /// </para> - /// <para> For some ILog interface <c>log</c>, when you write:</para> - /// <code lang="C#"> - /// log.Debug("This is entry number: " + i ); - /// </code> - /// <para> - /// You incur the cost constructing the message, string construction and concatenation in - /// this case, regardless of whether the message is logged or not. - /// </para> - /// <para> - /// If you are worried about speed (who isn't), then you should write: - /// </para> - /// <code lang="C#"> - /// if (log.IsDebugEnabled) - /// { - /// log.Debug("This is entry number: " + i ); - /// } - /// </code> - /// <para> - /// This way you will not incur the cost of parameter - /// construction if debugging is disabled for <c>log</c>. On - /// the other hand, if the <c>log</c> is debug enabled, you - /// will incur the cost of evaluating whether the logger is debug - /// enabled twice. Once in <see cref="IsDebugEnabled"/> and once in - /// the <see cref="Debug(object)"/>. This is an insignificant overhead - /// since evaluating a logger takes about 1% of the time it - /// takes to actually log. This is the preferred style of logging. - /// </para> - /// <para>Alternatively if your logger is available statically then the is debug - /// enabled state can be stored in a static variable like this: - /// </para> - /// <code lang="C#"> - /// private static readonly bool isDebugEnabled = log.IsDebugEnabled; - /// </code> - /// <para> - /// Then when you come to log you can write: - /// </para> - /// <code lang="C#"> - /// if (isDebugEnabled) - /// { - /// log.Debug("This is entry number: " + i ); - /// } - /// </code> - /// <para> - /// This way the debug enabled state is only queried once - /// when the class is loaded. Using a <c>private static readonly</c> - /// variable is the most efficient because it is a run time constant - /// and can be heavily optimized by the JIT compiler. - /// </para> - /// <para> - /// Of course if you use a static readonly variable to - /// hold the enabled state of the logger then you cannot - /// change the enabled state at runtime to vary the logging - /// that is produced. You have to decide if you need absolute - /// speed or runtime flexibility. - /// </para> - /// </remarks> - /// <seealso cref="Debug(object)"/> - /// <seealso cref="DebugFormat(string, object[])"/> - public static bool IsDebugEnabled { - get { return facade.IsDebugEnabled; } - } - - /// <summary> - /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Info"/> level. - /// </summary> - /// <value> - /// <c>true</c> if this logger is enabled for <see cref="Level.Info"/> events, <c>false</c> otherwise. - /// </value> - /// <remarks> - /// For more information see <see cref="ILog.IsDebugEnabled"/>. - /// </remarks> - /// <seealso cref="Info(object)"/> - /// <seealso cref="InfoFormat(string, object[])"/> - /// <seealso cref="ILog.IsDebugEnabled"/> - public static bool IsInfoEnabled { - get { return facade.IsInfoEnabled; } - } - - /// <summary> - /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Warn"/> level. - /// </summary> - /// <value> - /// <c>true</c> if this logger is enabled for <see cref="Level.Warn"/> events, <c>false</c> otherwise. - /// </value> - /// <remarks> - /// For more information see <see cref="ILog.IsDebugEnabled"/>. - /// </remarks> - /// <seealso cref="Warn(object)"/> - /// <seealso cref="WarnFormat(string, object[])"/> - /// <seealso cref="ILog.IsDebugEnabled"/> - public static bool IsWarnEnabled { - get { return facade.IsWarnEnabled; } - } - - /// <summary> - /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Error"/> level. - /// </summary> - /// <value> - /// <c>true</c> if this logger is enabled for <see cref="Level.Error"/> events, <c>false</c> otherwise. - /// </value> - /// <remarks> - /// For more information see <see cref="ILog.IsDebugEnabled"/>. - /// </remarks> - /// <seealso cref="Error(object)"/> - /// <seealso cref="ErrorFormat(string, object[])"/> - /// <seealso cref="ILog.IsDebugEnabled"/> - public static bool IsErrorEnabled { - get { return facade.IsErrorEnabled; } - } - - /// <summary> - /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Fatal"/> level. - /// </summary> - /// <value> - /// <c>true</c> if this logger is enabled for <see cref="Level.Fatal"/> events, <c>false</c> otherwise. - /// </value> - /// <remarks> - /// For more information see <see cref="ILog.IsDebugEnabled"/>. - /// </remarks> - /// <seealso cref="Fatal(object)"/> - /// <seealso cref="FatalFormat(string, object[])"/> - /// <seealso cref="ILog.IsDebugEnabled"/> - public static bool IsFatalEnabled { - get { return facade.IsFatalEnabled; } - } - - /// <overloads>Log a message object with the <see cref="Level.Debug"/> level.</overloads> - /// <summary> - /// Log a message object with the <see cref="Level.Debug"/> level. - /// </summary> - /// <param name="message">The message object to log.</param> - /// <remarks> - /// <para> - /// This method first checks if this logger is <c>DEBUG</c> - /// enabled by comparing the level of this logger with the - /// <see cref="Level.Debug"/> level. If this logger is - /// <c>DEBUG</c> enabled, then it converts the message object - /// (passed as parameter) to a string by invoking the appropriate - /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then - /// proceeds to call all the registered appenders in this logger - /// and also higher in the hierarchy depending on the value of - /// the additivity flag. - /// </para> - /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/> - /// to this method will print the name of the <see cref="Exception"/> - /// but no stack trace. To print a stack trace use the - /// <see cref="Debug(object,Exception)"/> form instead. - /// </para> - /// </remarks> - /// <seealso cref="Debug(object,Exception)"/> - /// <seealso cref="IsDebugEnabled"/> - public static void Debug(object message) { - facade.Debug(message); - } - - /// <summary> - /// Log a message object with the <see cref="Level.Debug"/> level including - /// the stack trace of the <see cref="Exception"/> passed - /// as a parameter. - /// </summary> - /// <param name="message">The message object to log.</param> - /// <param name="exception">The exception to log, including its stack trace.</param> - /// <remarks> - /// <para> - /// See the <see cref="Debug(object)"/> form for more detailed information. - /// </para> - /// </remarks> - /// <seealso cref="Debug(object)"/> - /// <seealso cref="IsDebugEnabled"/> - public static void Debug(object message, Exception exception) { - facade.Debug(message, exception); - } - - /// <overloads>Log a formatted string with the <see cref="Level.Debug"/> level.</overloads> - /// <summary> - /// Logs a formatted message string with the <see cref="Level.Debug"/> level. - /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="args">An Object array containing zero or more objects to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Debug(object)"/> - /// <seealso cref="IsDebugEnabled"/> - public static void DebugFormat(string format, params object[] args) { - facade.DebugFormat(CultureInfo.InvariantCulture, format, args); - } - - /// <summary> - /// Logs a formatted message string with the <see cref="Level.Debug"/> level. - /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Debug(object)"/> - /// <seealso cref="IsDebugEnabled"/> - public static void DebugFormat(string format, object arg0) { - facade.DebugFormat(format, arg0); - } - - /// <summary> - /// Logs a formatted message string with the <see cref="Level.Debug"/> level. - /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <param name="arg1">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Debug(object)"/> - /// <seealso cref="IsDebugEnabled"/> - public static void DebugFormat(string format, object arg0, object arg1) { - facade.DebugFormat(format, arg0, arg1); - } - - /// <summary> - /// Logs a formatted message string with the <see cref="Level.Debug"/> level. - /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <param name="arg1">An Object to format</param> - /// <param name="arg2">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Debug(object)"/> - /// <seealso cref="IsDebugEnabled"/> - public static void DebugFormat(string format, object arg0, object arg1, object arg2) { - facade.DebugFormat(format, arg0, arg1, arg2); - } - - /* - public static void DebugFormat(IFormatProvider provider, string format, params object[] args) { - facade.DebugFormat(provider, format, args); - } - */ - - /// <overloads>Log a message object with the <see cref="Level.Info"/> level.</overloads> - /// <summary> - /// Logs a message object with the <see cref="Level.Info"/> level. - /// </summary> - /// <remarks> - /// <para> - /// This method first checks if this logger is <c>INFO</c> - /// enabled by comparing the level of this logger with the - /// <see cref="Level.Info"/> level. If this logger is - /// <c>INFO</c> enabled, then it converts the message object - /// (passed as parameter) to a string by invoking the appropriate - /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then - /// proceeds to call all the registered appenders in this logger - /// and also higher in the hierarchy depending on the value of the - /// additivity flag. - /// </para> - /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/> - /// to this method will print the name of the <see cref="Exception"/> - /// but no stack trace. To print a stack trace use the - /// <see cref="Info(object,Exception)"/> form instead. - /// </para> - /// </remarks> - /// <param name="message">The message object to log.</param> - /// <seealso cref="Info(object,Exception)"/> - /// <seealso cref="IsInfoEnabled"/> - public static void Info(object message) { - facade.Info(message); - } - - /// <summary> - /// Logs a message object with the <c>INFO</c> level including - /// the stack trace of the <see cref="Exception"/> passed - /// as a parameter. - /// </summary> - /// <param name="message">The message object to log.</param> - /// <param name="exception">The exception to log, including its stack trace.</param> - /// <remarks> - /// <para> - /// See the <see cref="Info(object)"/> form for more detailed information. - /// </para> - /// </remarks> - /// <seealso cref="Info(object)"/> - /// <seealso cref="IsInfoEnabled"/> - public static void Info(object message, Exception exception) { - facade.Info(message, exception); - } - - /// <overloads>Log a formatted message string with the <see cref="Level.Info"/> level.</overloads> - /// <summary> - /// Logs a formatted message string with the <see cref="Level.Info"/> level. - /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="args">An Object array containing zero or more objects to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Info(object,Exception)"/> - /// <seealso cref="IsInfoEnabled"/> - public static void InfoFormat(string format, params object[] args) { - facade.InfoFormat(CultureInfo.InvariantCulture, format, args); - } + private static readonly ILog yadis = Create("DotNetOpenAuth.Yadis"); /// <summary> - /// Logs a formatted message string with the <see cref="Level.Info"/> level. + /// Backing field for the <see cref="Messaging"/> property. /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Info(object)"/> - /// <seealso cref="IsInfoEnabled"/> - public static void InfoFormat(string format, object arg0) { - facade.InfoFormat(format, arg0); - } + private static readonly ILog messaging = Create("DotNetOpenAuth.Messaging"); /// <summary> - /// Logs a formatted message string with the <see cref="Level.Info"/> level. + /// Backing field for the <see cref="Channel"/> property. /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <param name="arg1">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Info(object)"/> - /// <seealso cref="IsInfoEnabled"/> - public static void InfoFormat(string format, object arg0, object arg1) { - facade.InfoFormat(format, arg0, arg1); - } - - /// <summary> - /// Logs a formatted message string with the <see cref="Level.Info"/> level. - /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <param name="arg1">An Object to format</param> - /// <param name="arg2">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Info(object)"/> - /// <seealso cref="IsInfoEnabled"/> - public static void InfoFormat(string format, object arg0, object arg1, object arg2) { - facade.InfoFormat(format, arg0, arg1, arg2); - } - - /* - public static void InfoFormat(IFormatProvider provider, string format, params object[] args) { - facade.InfoFormat(provider, format, args); - } - */ + private static readonly ILog channel = Create("DotNetOpenAuth.Messaging.Channel"); - /// <overloads>Log a message object with the <see cref="Level.Warn"/> level.</overloads> /// <summary> - /// Log a message object with the <see cref="Level.Warn"/> level. + /// Backing field for the <see cref="Bindings"/> property. /// </summary> - /// <remarks> - /// <para> - /// This method first checks if this logger is <c>WARN</c> - /// enabled by comparing the level of this logger with the - /// <see cref="Level.Warn"/> level. If this logger is - /// <c>WARN</c> enabled, then it converts the message object - /// (passed as parameter) to a string by invoking the appropriate - /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then - /// proceeds to call all the registered appenders in this logger - /// and also higher in the hierarchy depending on the value of the - /// additivity flag. - /// </para> - /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/> - /// to this method will print the name of the <see cref="Exception"/> - /// but no stack trace. To print a stack trace use the - /// <see cref="Warn(object,Exception)"/> form instead. - /// </para> - /// </remarks> - /// <param name="message">The message object to log.</param> - /// <seealso cref="Warn(object,Exception)"/> - /// <seealso cref="IsWarnEnabled"/> - public static void Warn(object message) { - facade.Warn(message); - } + private static readonly ILog bindings = Create("DotNetOpenAuth.Messaging.Bindings"); /// <summary> - /// Log a message object with the <see cref="Level.Warn"/> level including - /// the stack trace of the <see cref="Exception"/> passed - /// as a parameter. + /// Backing field for the <see cref="Signatures"/> property. /// </summary> - /// <param name="message">The message object to log.</param> - /// <param name="exception">The exception to log, including its stack trace.</param> - /// <remarks> - /// <para> - /// See the <see cref="Warn(object)"/> form for more detailed information. - /// </para> - /// </remarks> - /// <seealso cref="Warn(object)"/> - /// <seealso cref="IsWarnEnabled"/> - public static void Warn(object message, Exception exception) { - facade.Warn(message, exception); - } + private static readonly ILog signatures = Create("DotNetOpenAuth.Messaging.Bindings.Signatures"); - /// <overloads>Log a formatted message string with the <see cref="Level.Warn"/> level.</overloads> /// <summary> - /// Logs a formatted message string with the <see cref="Level.Warn"/> level. + /// Backing field for the <see cref="Http"/> property. /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="args">An Object array containing zero or more objects to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Warn(object,Exception)"/> - /// <seealso cref="IsWarnEnabled"/> - public static void WarnFormat(string format, params object[] args) { - facade.WarnFormat(CultureInfo.InvariantCulture, format, args); - } + private static readonly ILog http = Create("DotNetOpenAuth.Http"); /// <summary> - /// Logs a formatted message string with the <see cref="Level.Warn"/> level. + /// Backing field for the <see cref="OpenId"/> property. /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Warn(object)"/> - /// <seealso cref="IsWarnEnabled"/> - public static void WarnFormat(string format, object arg0) { - facade.WarnFormat(format, arg0); - } + private static readonly ILog openId = Create("DotNetOpenAuth.OpenId"); /// <summary> - /// Logs a formatted message string with the <see cref="Level.Warn"/> level. + /// Backing field for the <see cref="OAuth"/> property. /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <param name="arg1">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Warn(object)"/> - /// <seealso cref="IsWarnEnabled"/> - public static void WarnFormat(string format, object arg0, object arg1) { - facade.WarnFormat(format, arg0, arg1); - } + private static readonly ILog oauth = Create("DotNetOpenAuth.OAuth"); /// <summary> - /// Logs a formatted message string with the <see cref="Level.Warn"/> level. + /// Gets the logger for service discovery and selection events. /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <param name="arg1">An Object to format</param> - /// <param name="arg2">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Warn(object)"/> - /// <seealso cref="IsWarnEnabled"/> - public static void WarnFormat(string format, object arg0, object arg1, object arg2) { - facade.WarnFormat(format, arg0, arg1, arg2); - } + internal static ILog Yadis { get { return yadis; } } - /* - public static void WarnFormat(IFormatProvider provider, string format, params object[] args) { - facade.WarnFormat(provider, format, args); - } - */ - - /// <overloads>Log a message object with the <see cref="Level.Error"/> level.</overloads> /// <summary> - /// Logs a message object with the <see cref="Level.Error"/> level. + /// Gets the logger for Messaging events. /// </summary> - /// <param name="message">The message object to log.</param> - /// <remarks> - /// <para> - /// This method first checks if this logger is <c>ERROR</c> - /// enabled by comparing the level of this logger with the - /// <see cref="Level.Error"/> level. If this logger is - /// <c>ERROR</c> enabled, then it converts the message object - /// (passed as parameter) to a string by invoking the appropriate - /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then - /// proceeds to call all the registered appenders in this logger - /// and also higher in the hierarchy depending on the value of the - /// additivity flag. - /// </para> - /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/> - /// to this method will print the name of the <see cref="Exception"/> - /// but no stack trace. To print a stack trace use the - /// <see cref="Error(object,Exception)"/> form instead. - /// </para> - /// </remarks> - /// <seealso cref="Error(object,Exception)"/> - /// <seealso cref="IsErrorEnabled"/> - public static void Error(object message) { - facade.Error(message); - } + internal static ILog Messaging { get { return messaging; } } /// <summary> - /// Log a message object with the <see cref="Level.Error"/> level including - /// the stack trace of the <see cref="Exception"/> passed - /// as a parameter. + /// Gets the logger for Channel events. /// </summary> - /// <param name="message">The message object to log.</param> - /// <param name="exception">The exception to log, including its stack trace.</param> - /// <remarks> - /// <para> - /// See the <see cref="Error(object)"/> form for more detailed information. - /// </para> - /// </remarks> - /// <seealso cref="Error(object)"/> - /// <seealso cref="IsErrorEnabled"/> - public static void Error(object message, Exception exception) { - facade.Error(message, exception); - } + internal static ILog Channel { get { return channel; } } - /// <overloads>Log a formatted message string with the <see cref="Level.Error"/> level.</overloads> /// <summary> - /// Logs a formatted message string with the <see cref="Level.Error"/> level. + /// Gets the logger for binding elements and binding-element related events on the channel. /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="args">An Object array containing zero or more objects to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Error(object,Exception)"/> - /// <seealso cref="IsErrorEnabled"/> - public static void ErrorFormat(string format, params object[] args) { - facade.ErrorFormat(CultureInfo.InvariantCulture, format, args); - } + internal static ILog Bindings { get { return bindings; } } /// <summary> - /// Logs a formatted message string with the <see cref="Level.Error"/> level. + /// Gets the logger specifically used for logging verbose text on everything about the signing process. /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Error(object)"/> - /// <seealso cref="IsErrorEnabled"/> - public static void ErrorFormat(string format, object arg0) { - facade.ErrorFormat(format, arg0); - } + internal static ILog Signatures { get { return signatures; } } /// <summary> - /// Logs a formatted message string with the <see cref="Level.Error"/> level. + /// Gets the logger for HTTP-level events. /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <param name="arg1">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Error(object)"/> - /// <seealso cref="IsErrorEnabled"/> - public static void ErrorFormat(string format, object arg0, object arg1) { - facade.ErrorFormat(format, arg0, arg1); - } + internal static ILog Http { get { return http; } } /// <summary> - /// Logs a formatted message string with the <see cref="Level.Error"/> level. + /// Gets the logger for high-level OpenID events. /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <param name="arg1">An Object to format</param> - /// <param name="arg2">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Error(object)"/> - /// <seealso cref="IsErrorEnabled"/> - public static void ErrorFormat(string format, object arg0, object arg1, object arg2) { - facade.ErrorFormat(format, arg0, arg1, arg2); - } - - /* - public static void ErrorFormat(IFormatProvider provider, string format, params object[] args) { - facade.ErrorFormat(provider, format, args); - } - */ + internal static ILog OpenId { get { return openId; } } - /// <overloads>Log a message object with the <see cref="Level.Fatal"/> level.</overloads> /// <summary> - /// Log a message object with the <see cref="Level.Fatal"/> level. + /// Gets the logger for high-level OAuth events. /// </summary> - /// <remarks> - /// <para> - /// This method first checks if this logger is <c>FATAL</c> - /// enabled by comparing the level of this logger with the - /// <see cref="Level.Fatal"/> level. If this logger is - /// <c>FATAL</c> enabled, then it converts the message object - /// (passed as parameter) to a string by invoking the appropriate - /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then - /// proceeds to call all the registered appenders in this logger - /// and also higher in the hierarchy depending on the value of the - /// additivity flag. - /// </para> - /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/> - /// to this method will print the name of the <see cref="Exception"/> - /// but no stack trace. To print a stack trace use the - /// <see cref="Fatal(object,Exception)"/> form instead. - /// </para> - /// </remarks> - /// <param name="message">The message object to log.</param> - /// <seealso cref="Fatal(object,Exception)"/> - /// <seealso cref="IsFatalEnabled"/> - public static void Fatal(object message) { - facade.Fatal(message); - } - - /// <summary> - /// Log a message object with the <see cref="Level.Fatal"/> level including - /// the stack trace of the <see cref="Exception"/> passed - /// as a parameter. - /// </summary> - /// <param name="message">The message object to log.</param> - /// <param name="exception">The exception to log, including its stack trace.</param> - /// <remarks> - /// <para> - /// See the <see cref="Fatal(object)"/> form for more detailed information. - /// </para> - /// </remarks> - /// <seealso cref="Fatal(object)"/> - /// <seealso cref="IsFatalEnabled"/> - public static void Fatal(object message, Exception exception) { - facade.Fatal(message, exception); - } - - /// <overloads>Log a formatted message string with the <see cref="Level.Fatal"/> level.</overloads> - /// <summary> - /// Logs a formatted message string with the <see cref="Level.Fatal"/> level. - /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="args">An Object array containing zero or more objects to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Fatal(object,Exception)"/> - /// <seealso cref="IsFatalEnabled"/> - public static void FatalFormat(string format, params object[] args) { - facade.FatalFormat(CultureInfo.InvariantCulture, format, args); - } - - /// <summary> - /// Logs a formatted message string with the <see cref="Level.Fatal"/> level. - /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Fatal(object)"/> - /// <seealso cref="IsFatalEnabled"/> - public static void FatalFormat(string format, object arg0) { - facade.FatalFormat(format, arg0); - } - - /// <summary> - /// Logs a formatted message string with the <see cref="Level.Fatal"/> level. - /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <param name="arg1">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Fatal(object)"/> - /// <seealso cref="IsFatalEnabled"/> - public static void FatalFormat(string format, object arg0, object arg1) { - facade.FatalFormat(format, arg0, arg1); - } - - /// <summary> - /// Logs a formatted message string with the <see cref="Level.Fatal"/> level. - /// </summary> - /// <param name="format">A String containing zero or more format items</param> - /// <param name="arg0">An Object to format</param> - /// <param name="arg1">An Object to format</param> - /// <param name="arg2">An Object to format</param> - /// <remarks> - /// <para> - /// The message is formatted using the <c>String.Format</c> method. See - /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior - /// of the formatting. - /// </para> - /// <para> - /// This method does not take an <see cref="Exception"/> object to include in the - /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/> - /// methods instead. - /// </para> - /// </remarks> - /// <seealso cref="Fatal(object)"/> - /// <seealso cref="IsFatalEnabled"/> - public static void FatalFormat(string format, object arg0, object arg1, object arg2) { - facade.FatalFormat(format, arg0, arg1, arg2); - } - - /* - public static void FatalFormat(IFormatProvider provider, string format, params object[] args) { - facade.FatalFormat(provider, format, args); - } - */ + internal static ILog OAuth { get { return oauth; } } #endregion @@ -919,14 +116,23 @@ namespace DotNetOpenAuth { /// <param name="name">A name that will be included in the log file.</param> /// <returns>The <see cref="ILog"/> instance created with the given name.</returns> internal static ILog Create(string name) { - if (String.IsNullOrEmpty(name)) { - throw new ArgumentNullException("name"); - } - + ErrorUtilities.VerifyNonZeroLength(name, "name"); return InitializeFacade(name); } /// <summary> + /// Creates the main logger for the library, and emits an INFO message + /// that is the name and version of the library. + /// </summary> + /// <param name="name">A name that will be included in the log file.</param> + /// <returns>The <see cref="ILog"/> instance created with the given name.</returns> + internal static ILog CreateWithBanner(string name) { + ILog log = Create(name); + log.Info(Util.LibraryVersion); + return log; + } + + /// <summary> /// Creates an additional logger on demand for a subsection of the application. /// </summary> /// <param name="type">A type whose full name that will be included in the log file.</param> @@ -947,7 +153,6 @@ namespace DotNetOpenAuth { /// <returns>The <see cref="ILog"/> instance of the logger to use.</returns> private static ILog InitializeFacade(string name) { ILog result = Log4NetLogger.Initialize(name) ?? TraceLogger.Initialize(name) ?? NoOpLogger.Initialize(); - result.Info(Util.LibraryVersion); return result; } } diff --git a/src/DotNetOpenAuth/Messaging/Channel.cs b/src/DotNetOpenAuth/Messaging/Channel.cs index a1220e5..2c5752d 100644 --- a/src/DotNetOpenAuth/Messaging/Channel.cs +++ b/src/DotNetOpenAuth/Messaging/Channel.cs @@ -235,7 +235,7 @@ namespace DotNetOpenAuth.Messaging { ErrorUtilities.VerifyArgumentNotNull(message, "message"); this.ProcessOutgoingMessage(message); - Logger.DebugFormat("Sending message: {0}", message); + Logger.Channel.DebugFormat("Sending message: {0}", message.GetType().Name); switch (message.Transport) { case MessageTransport.Direct: @@ -360,7 +360,7 @@ namespace DotNetOpenAuth.Messaging { Contract.Requires(httpRequest != null); IDirectedProtocolMessage requestMessage = this.ReadFromRequestCore(httpRequest); if (requestMessage != null) { - Logger.DebugFormat("Incoming request received: {0}", requestMessage); + Logger.Channel.DebugFormat("Incoming request received: {0}", requestMessage.GetType().Name); this.ProcessIncomingMessage(requestMessage); } @@ -401,11 +401,11 @@ namespace DotNetOpenAuth.Messaging { ErrorUtilities.VerifyArgumentNotNull(requestMessage, "requestMessage"); this.ProcessOutgoingMessage(requestMessage); - Logger.DebugFormat("Sending request: {0}", requestMessage); + Logger.Channel.DebugFormat("Sending {0} request.", requestMessage.GetType().Name); var responseMessage = this.RequestCore(requestMessage); ErrorUtilities.VerifyProtocol(responseMessage != null, MessagingStrings.ExpectedMessageNotReceived, typeof(IProtocolMessage).Name); - Logger.DebugFormat("Received message response: {0}", responseMessage); + Logger.Channel.DebugFormat("Received {0} response.", responseMessage.GetType().Name); this.ProcessIncomingMessage(responseMessage); return responseMessage; @@ -534,7 +534,7 @@ namespace DotNetOpenAuth.Messaging { Contract.Requires(request != null); ErrorUtilities.VerifyArgumentNotNull(request, "request"); - Logger.DebugFormat("Incoming HTTP request: {0}", request.Url.AbsoluteUri); + Logger.Channel.DebugFormat("Incoming HTTP request: {0}", request.Url.AbsoluteUri); // Search Form data first, and if nothing is there search the QueryString Contract.Assume(request.Form != null && request.QueryString != null); @@ -617,7 +617,7 @@ namespace DotNetOpenAuth.Messaging { UriBuilder builder = new UriBuilder(message.Recipient); MessagingUtilities.AppendQueryArgs(builder, fields); headers.Add(HttpResponseHeader.Location, builder.Uri.AbsoluteUri); - Logger.DebugFormat("Redirecting to {0}", builder.Uri.AbsoluteUri); + Logger.Http.DebugFormat("Redirecting to {0}", builder.Uri.AbsoluteUri); OutgoingWebResponse response = new OutgoingWebResponse { Status = HttpStatusCode.Redirect, Headers = headers, @@ -713,7 +713,7 @@ namespace DotNetOpenAuth.Messaging { Contract.Requires(message != null); ErrorUtilities.VerifyArgumentNotNull(message, "message"); - Logger.DebugFormat("Preparing to send {0} ({1}) message.", message.GetType().Name, message.Version); + Logger.Channel.DebugFormat("Preparing to send {0} ({1}) message.", message.GetType().Name, message.Version); this.OnSending(message); // Give the message a chance to do custom serialization. @@ -726,14 +726,14 @@ namespace DotNetOpenAuth.Messaging { foreach (IChannelBindingElement bindingElement in this.outgoingBindingElements) { MessageProtections? elementProtection = bindingElement.ProcessOutgoingMessage(message); if (elementProtection.HasValue) { - Logger.DebugFormat("Binding element {0} applied to message.", bindingElement.GetType().FullName); + Logger.Bindings.DebugFormat("Binding element {0} applied to message.", bindingElement.GetType().FullName); // Ensure that only one protection binding element applies to this message // for each protection type. ErrorUtilities.VerifyProtocol((appliedProtection & elementProtection.Value) == 0, MessagingStrings.TooManyBindingsOfferingSameProtection, elementProtection.Value); appliedProtection |= elementProtection.Value; } else { - Logger.DebugFormat("Binding element {0} did not apply to message.", bindingElement.GetType().FullName); + Logger.Bindings.DebugFormat("Binding element {0} did not apply to message.", bindingElement.GetType().FullName); } } @@ -745,10 +745,10 @@ namespace DotNetOpenAuth.Messaging { this.EnsureValidMessageParts(message); message.EnsureValidMessage(); - if (Logger.IsDebugEnabled) { + if (Logger.Channel.IsInfoEnabled) { var messageAccessor = this.MessageDescriptions.GetAccessor(message); - Logger.DebugFormat( - "Sending {0} ({1}) message: {2}{3}", + Logger.Channel.InfoFormat( + "Prepared outgoing {0} ({1}) message: {2}{3}", message.GetType().Name, message.Version, Environment.NewLine, @@ -836,10 +836,10 @@ namespace DotNetOpenAuth.Messaging { protected virtual void ProcessIncomingMessage(IProtocolMessage message) { Contract.Requires(message != null); - if (Logger.IsDebugEnabled) { + if (Logger.Channel.IsInfoEnabled) { var messageAccessor = this.MessageDescriptions.GetAccessor(message); - Logger.DebugFormat( - "Preparing to receive {0} ({1}) message:{2}{3}", + Logger.Channel.InfoFormat( + "Processing incoming {0} ({1}) message:{2}{3}", message.GetType().Name, message.Version, Environment.NewLine, @@ -850,7 +850,7 @@ namespace DotNetOpenAuth.Messaging { foreach (IChannelBindingElement bindingElement in this.incomingBindingElements) { MessageProtections? elementProtection = bindingElement.ProcessIncomingMessage(message); if (elementProtection.HasValue) { - Logger.DebugFormat("Binding element {0} applied to message.", bindingElement.GetType().FullName); + Logger.Bindings.DebugFormat("Binding element {0} applied to message.", bindingElement.GetType().FullName); // Ensure that only one protection binding element applies to this message // for each protection type. @@ -861,12 +861,12 @@ namespace DotNetOpenAuth.Messaging { // their own replay protection for OpenID 1.x, and the OP happens to reuse // openid.response_nonce, then this RP may consider both the RP's own nonce and // the OP's nonce and "apply" replay protection twice. This actually isn't a problem. - Logger.WarnFormat(MessagingStrings.TooManyBindingsOfferingSameProtection, elementProtection.Value); + Logger.Bindings.WarnFormat(MessagingStrings.TooManyBindingsOfferingSameProtection, elementProtection.Value); } appliedProtection |= elementProtection.Value; } else { - Logger.DebugFormat("Binding element {0} did not apply to message.", bindingElement.GetType().FullName); + Logger.Bindings.DebugFormat("Binding element {0} did not apply to message.", bindingElement.GetType().FullName); } } @@ -881,6 +881,16 @@ namespace DotNetOpenAuth.Messaging { eventedMessage.OnReceiving(); } + if (Logger.Channel.IsDebugEnabled) { + var messageAccessor = this.MessageDescriptions.GetAccessor(message); + Logger.Channel.DebugFormat( + "After binding element processing, the received {0} ({1}) message is: {2}{3}", + message.GetType().Name, + message.Version, + Environment.NewLine, + messageAccessor.ToStringDeferred()); + } + // We do NOT verify that all required message parts are present here... the // message deserializer did for us. It would be too late to do it here since // they might look initialized by the time we have an IProtocolMessage instance. diff --git a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs index 259b450..6434373 100644 --- a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs +++ b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs @@ -138,7 +138,7 @@ namespace DotNetOpenAuth.Messaging { } /// <summary> - /// Assemblies a message comprised of the message on a given exception and all inner exceptions. + /// Assembles a message comprised of the message on a given exception and all inner exceptions. /// </summary> /// <param name="exception">The exception.</param> /// <returns>The assembled message.</returns> @@ -147,7 +147,7 @@ namespace DotNetOpenAuth.Messaging { // from a catch block, we don't really want to throw a new exception and // hide the details of this one. if (exception == null) { - Logger.Error("MessagingUtilities.GetAllMessages called with null input."); + Logger.Messaging.Error("MessagingUtilities.GetAllMessages called with null input."); } StringBuilder message = new StringBuilder(); @@ -582,7 +582,7 @@ namespace DotNetOpenAuth.Messaging { if (throwOnNullKey) { throw new ArgumentException(MessagingStrings.UnexpectedNullKey); } else { - Logger.WarnFormat("Null key with value {0} encountered while translating NameValueCollection to Dictionary.", nvc[key]); + Logger.OpenId.WarnFormat("Null key with value {0} encountered while translating NameValueCollection to Dictionary.", nvc[key]); } } else { dictionary.Add(key, nvc[key]); diff --git a/src/DotNetOpenAuth/Messaging/Reflection/MessageDescription.cs b/src/DotNetOpenAuth/Messaging/Reflection/MessageDescription.cs index 3512d42..5cb7877 100644 --- a/src/DotNetOpenAuth/Messaging/Reflection/MessageDescription.cs +++ b/src/DotNetOpenAuth/Messaging/Reflection/MessageDescription.cs @@ -97,7 +97,7 @@ namespace DotNetOpenAuth.Messaging.Reflection { if (partAttribute != null) { MessagePart part = new MessagePart(member, partAttribute); if (this.mapping.ContainsKey(part.Name)) { - Logger.WarnFormat( + Logger.Messaging.WarnFormat( "Message type {0} has more than one message part named {1}. Inherited members will be hidden.", this.messageType.Name, part.Name); diff --git a/src/DotNetOpenAuth/Messaging/StandardWebRequestHandler.cs b/src/DotNetOpenAuth/Messaging/StandardWebRequestHandler.cs index b2594bd..e8d8fe1 100644 --- a/src/DotNetOpenAuth/Messaging/StandardWebRequestHandler.cs +++ b/src/DotNetOpenAuth/Messaging/StandardWebRequestHandler.cs @@ -126,7 +126,7 @@ namespace DotNetOpenAuth.Messaging { PrepareRequest(request, false); try { - Logger.DebugFormat("HTTP {0} {1}", request.Method, request.RequestUri); + Logger.Http.DebugFormat("HTTP {0} {1}", request.Method, request.RequestUri); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); return new NetworkDirectWebResponse(request.RequestUri, response); } catch (WebException ex) { @@ -149,17 +149,17 @@ namespace DotNetOpenAuth.Messaging { if ((options & DirectWebRequestOptions.AcceptAllHttpResponses) != 0 && response != null && response.StatusCode != HttpStatusCode.ExpectationFailed) { - Logger.InfoFormat("The HTTP error code {0} {1} is being accepted because the {2} flag is set.", (int)response.StatusCode, response.StatusCode, DirectWebRequestOptions.AcceptAllHttpResponses); + Logger.Http.InfoFormat("The HTTP error code {0} {1} is being accepted because the {2} flag is set.", (int)response.StatusCode, response.StatusCode, DirectWebRequestOptions.AcceptAllHttpResponses); return new NetworkDirectWebResponse(request.RequestUri, response); } - if (Logger.IsErrorEnabled) { + if (Logger.Http.IsErrorEnabled) { if (response != null) { using (var reader = new StreamReader(ex.Response.GetResponseStream())) { - Logger.ErrorFormat("WebException from {0}: {1}{2}", ex.Response.ResponseUri, Environment.NewLine, reader.ReadToEnd()); + Logger.Http.ErrorFormat("WebException from {0}: {1}{2}", ex.Response.ResponseUri, Environment.NewLine, reader.ReadToEnd()); } } else { - Logger.ErrorFormat("WebException {1} from {0}, no response available.", request.RequestUri, ex.Status); + Logger.Http.ErrorFormat("WebException {1} from {0}, no response available.", request.RequestUri, ex.Status); } } diff --git a/src/DotNetOpenAuth/Messaging/UntrustedWebRequestHandler.cs b/src/DotNetOpenAuth/Messaging/UntrustedWebRequestHandler.cs index 7021b36..4adf3a7 100644 --- a/src/DotNetOpenAuth/Messaging/UntrustedWebRequestHandler.cs +++ b/src/DotNetOpenAuth/Messaging/UntrustedWebRequestHandler.cs @@ -394,7 +394,7 @@ namespace DotNetOpenAuth.Messaging { private bool IsUriAllowable(Uri uri) { ErrorUtilities.VerifyArgumentNotNull(uri, "uri"); if (!this.allowableSchemes.Contains(uri.Scheme)) { - Logger.WarnFormat("Rejecting URL {0} because it uses a disallowed scheme.", uri); + Logger.Http.WarnFormat("Rejecting URL {0} because it uses a disallowed scheme.", uri); return false; } @@ -403,7 +403,7 @@ namespace DotNetOpenAuth.Messaging { if (IsHostWhitelisted(uri.DnsSafeHost)) { return true; } - Logger.WarnFormat("Rejecting URL {0} because {1}.", uri, reason); + Logger.Http.WarnFormat("Rejecting URL {0} because {1}.", uri, reason); return false; }; @@ -440,7 +440,7 @@ namespace DotNetOpenAuth.Messaging { } } if (this.IsHostBlacklisted(uri.DnsSafeHost)) { - Logger.WarnFormat("Rejected URL {0} because it is blacklisted.", uri); + Logger.Http.WarnFormat("Rejected URL {0} because it is blacklisted.", uri); return false; } return true; diff --git a/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthChannel.cs b/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthChannel.cs index f556a1d..f8fc7f4 100644 --- a/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthChannel.cs +++ b/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthChannel.cs @@ -285,7 +285,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { private void SignatureCallback(ITamperResistantProtocolMessage message) { var oauthMessage = message as ITamperResistantOAuthMessage; try { - Logger.Debug("Applying secrets to message to prepare for signing or signature verification."); + Logger.Channel.Debug("Applying secrets to message to prepare for signing or signature verification."); oauthMessage.ConsumerSecret = this.TokenManager.GetConsumerSecret(oauthMessage.ConsumerKey); var tokenMessage = message as ITokenContainingMessage; diff --git a/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthConsumerMessageFactory.cs b/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthConsumerMessageFactory.cs index 5bcac58..fce351b 100644 --- a/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthConsumerMessageFactory.cs +++ b/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthConsumerMessageFactory.cs @@ -85,7 +85,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { // All direct message responses should have the oauth_token_secret field. if (!fields.ContainsKey("oauth_token_secret")) { - Logger.Error("An OAuth message was expected to contain an oauth_token_secret but didn't."); + Logger.OAuth.Error("An OAuth message was expected to contain an oauth_token_secret but didn't."); return null; } @@ -96,7 +96,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { } else if (authorizedTokenRequest != null) { message = new AuthorizedTokenResponse(authorizedTokenRequest); } else { - Logger.ErrorFormat("Unexpected response message given the request type {0}", request.GetType().Name); + Logger.OAuth.ErrorFormat("Unexpected response message given the request type {0}", request.GetType().Name); throw new ProtocolException(OAuthStrings.InvalidIncomingMessage); } diff --git a/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthServiceProviderMessageFactory.cs b/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthServiceProviderMessageFactory.cs index cd900cf..16f8a79 100644 --- a/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthServiceProviderMessageFactory.cs +++ b/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthServiceProviderMessageFactory.cs @@ -100,7 +100,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { ErrorUtilities.VerifyArgumentNotNull(request, "request"); ErrorUtilities.VerifyArgumentNotNull(fields, "fields"); - Logger.Error("Service Providers are not expected to ever receive responses."); + Logger.OAuth.Error("Service Providers are not expected to ever receive responses."); return null; } diff --git a/src/DotNetOpenAuth/OAuth/ChannelElements/RsaSha1SigningBindingElement.cs b/src/DotNetOpenAuth/OAuth/ChannelElements/RsaSha1SigningBindingElement.cs index dd8bbfc..b18ddb3 100644 --- a/src/DotNetOpenAuth/OAuth/ChannelElements/RsaSha1SigningBindingElement.cs +++ b/src/DotNetOpenAuth/OAuth/ChannelElements/RsaSha1SigningBindingElement.cs @@ -91,7 +91,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { X509Certificate2 cert = this.ConsumerCertificateProvider.GetCertificate(message); if (cert == null) { - Logger.WarnFormat("Incoming message from consumer '{0}' could not be matched with an appropriate X.509 certificate for signature verification.", message.ConsumerKey); + Logger.Signatures.WarnFormat("Incoming message from consumer '{0}' could not be matched with an appropriate X.509 certificate for signature verification.", message.ConsumerKey); return false; } diff --git a/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs b/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs index 18757ba..8cda939 100644 --- a/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs +++ b/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs @@ -86,11 +86,11 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { if (this.SignatureCallback != null) { this.SignatureCallback(signedMessage); } else { - Logger.Warn("Signing required, but callback delegate was not provided to provide additional data for signing."); + Logger.Bindings.Warn("Signing required, but callback delegate was not provided to provide additional data for signing."); } signedMessage.SignatureMethod = this.signatureMethod; - Logger.DebugFormat("Signing {0} message using {1}.", message.GetType().Name, this.signatureMethod); + Logger.Bindings.DebugFormat("Signing {0} message using {1}.", message.GetType().Name, this.signatureMethod); signedMessage.Signature = this.GetSignature(signedMessage); return MessageProtections.TamperProtection; } @@ -110,21 +110,21 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { public MessageProtections? ProcessIncomingMessage(IProtocolMessage message) { var signedMessage = message as ITamperResistantOAuthMessage; if (signedMessage != null && this.IsMessageApplicable(signedMessage)) { - Logger.DebugFormat("Verifying incoming {0} message signature of: {1}", message.GetType().Name, signedMessage.Signature); + Logger.Bindings.DebugFormat("Verifying incoming {0} message signature of: {1}", message.GetType().Name, signedMessage.Signature); if (!string.Equals(signedMessage.SignatureMethod, this.signatureMethod, StringComparison.Ordinal)) { - Logger.WarnFormat("Expected signature method '{0}' but received message with a signature method of '{1}'.", this.signatureMethod, signedMessage.SignatureMethod); + Logger.Bindings.WarnFormat("Expected signature method '{0}' but received message with a signature method of '{1}'.", this.signatureMethod, signedMessage.SignatureMethod); return MessageProtections.None; } if (this.SignatureCallback != null) { this.SignatureCallback(signedMessage); } else { - Logger.Warn("Signature verification required, but callback delegate was not provided to provide additional data for signature verification."); + Logger.Bindings.Warn("Signature verification required, but callback delegate was not provided to provide additional data for signature verification."); } if (!this.IsSignatureValid(signedMessage)) { - Logger.Error("Signature verification failed."); + Logger.Bindings.Error("Signature verification failed."); throw new InvalidSignatureException(message); } @@ -195,7 +195,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { signatureBaseString.Append(Uri.EscapeDataString(element)); } - Logger.DebugFormat("Constructed signature base string: {0}", signatureBaseString); + Logger.Bindings.DebugFormat("Constructed signature base string: {0}", signatureBaseString); return signatureBaseString.ToString(); } diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs index 2102957..d9fb90d 100644 --- a/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs +++ b/src/DotNetOpenAuth/OpenId/ChannelElements/ExtensionsBindingElement.cs @@ -121,7 +121,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { var extensionDictionary = this.Channel.MessageDescriptions.GetAccessor(extension).Serialize(); extensionManager.AddExtensionArguments(extension.TypeUri, extensionDictionary); } else { - Logger.WarnFormat("Unexpected extension type {0} did not implement {1}.", protocolExtension.GetType(), typeof(IOpenIdMessageExtension).Name); + Logger.OpenId.WarnFormat("Unexpected extension type {0} did not implement {1}.", protocolExtension.GetType(), typeof(IOpenIdMessageExtension).Name); } } @@ -181,7 +181,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { extendableMessage.Extensions.Add(extension); } else { - Logger.WarnFormat("Extension with type URI '{0}' ignored because it is not a recognized extension.", typeUri); + Logger.OpenId.WarnFormat("Extension with type URI '{0}' ignored because it is not a recognized extension.", typeUri); } } diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs index c13df36..f89ac73 100644 --- a/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs +++ b/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs @@ -263,9 +263,9 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { // Filter the responses to the allowable set of HTTP status codes. if (response.Status != HttpStatusCode.OK && response.Status != HttpStatusCode.BadRequest) { - if (Logger.IsErrorEnabled) { + if (Logger.Channel.IsErrorEnabled) { using (var reader = new StreamReader(response.ResponseStream)) { - Logger.ErrorFormat( + Logger.Channel.ErrorFormat( "Unexpected HTTP status code {0} {1} received in direct response:{2}{3}", (int)response.Status, response.Status, diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/ReturnToSignatureBindingElement.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/ReturnToSignatureBindingElement.cs index 1515298..fca634a 100644 --- a/src/DotNetOpenAuth/OpenId/ChannelElements/ReturnToSignatureBindingElement.cs +++ b/src/DotNetOpenAuth/OpenId/ChannelElements/ReturnToSignatureBindingElement.cs @@ -138,7 +138,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { actual = OpenIdUtilities.FixDoublyUriDecodedBase64String(actual); response.ReturnToParametersSignatureValidated = actual == expected; if (!response.ReturnToParametersSignatureValidated) { - Logger.WarnFormat("The return_to signature failed verification."); + Logger.Bindings.WarnFormat("The return_to signature failed verification."); } return MessageProtections.None; @@ -175,7 +175,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { sortedReturnToParameters.Add(key, returnToParameters[key]); } - Logger.DebugFormat("ReturnTo signed data: {0}{1}", Environment.NewLine, sortedReturnToParameters.ToStringDeferred()); + Logger.Bindings.DebugFormat("ReturnTo signed data: {0}{1}", Environment.NewLine, sortedReturnToParameters.ToStringDeferred()); // Sign the parameters. byte[] bytesToSign = KeyValueFormEncoding.GetBytes(sortedReturnToParameters); diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/SigningBindingElement.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/SigningBindingElement.cs index d755426..1527d33 100644 --- a/src/DotNetOpenAuth/OpenId/ChannelElements/SigningBindingElement.cs +++ b/src/DotNetOpenAuth/OpenId/ChannelElements/SigningBindingElement.cs @@ -42,11 +42,6 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { private readonly ProviderSecuritySettings opSecuritySettings; /// <summary> - /// A logger specifically used for logging verbose text on everything about the signing process. - /// </summary> - private static ILog signingLogger = Logger.Create(typeof(SigningBindingElement)); - - /// <summary> /// Initializes a new instance of the SigningBindingElement class for use by a Relying Party. /// </summary> /// <param name="associationStore">The association store used to look up the secrets needed for signing. May be null for dumb Relying Parties.</param> @@ -104,7 +99,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { public MessageProtections? ProcessOutgoingMessage(IProtocolMessage message) { var signedMessage = message as ITamperResistantOpenIdMessage; if (signedMessage != null) { - Logger.DebugFormat("Signing {0} message.", message.GetType().Name); + Logger.Bindings.DebugFormat("Signing {0} message.", message.GetType().Name); Association association = this.GetAssociation(signedMessage); signedMessage.AssociationHandle = association.Handle; signedMessage.SignedParameterOrder = this.GetSignedParameterOrder(signedMessage); @@ -131,7 +126,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { public MessageProtections? ProcessIncomingMessage(IProtocolMessage message) { var signedMessage = message as ITamperResistantOpenIdMessage; if (signedMessage != null) { - Logger.DebugFormat("Verifying incoming {0} message signature of: {1}", message.GetType().Name, signedMessage.Signature); + Logger.Bindings.DebugFormat("Verifying incoming {0} message signature of: {1}", message.GetType().Name, signedMessage.Signature); MessageProtections protectionsApplied = MessageProtections.TamperProtection; this.EnsureParametersRequiringSignatureAreSigned(signedMessage); @@ -140,7 +135,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { if (association != null) { string signature = this.GetSignature(signedMessage, association); if (!string.Equals(signedMessage.Signature, signature, StringComparison.Ordinal)) { - Logger.Error("Signature verification failed."); + Logger.Bindings.Error("Signature verification failed."); throw new InvalidSignatureException(message); } } else { @@ -158,7 +153,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { var checkSignatureRequest = new CheckAuthenticationRequest(indirectSignedResponse, this.Channel); var checkSignatureResponse = this.Channel.Request<CheckAuthenticationResponse>(checkSignatureRequest); if (!checkSignatureResponse.IsValid) { - Logger.Error("Provider reports signature verification failed."); + Logger.Bindings.Error("Provider reports signature verification failed."); throw new InvalidSignatureException(message); } @@ -269,8 +264,8 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { byte[] dataToSign = KeyValueFormEncoding.GetBytes(parametersToSign); string signature = Convert.ToBase64String(association.Sign(dataToSign)); - if (signingLogger.IsDebugEnabled) { - signingLogger.DebugFormat( + if (Logger.Signatures.IsDebugEnabled) { + Logger.Signatures.DebugFormat( CultureInfo.InvariantCulture, "Signing these message parts: {0}{1}{0}Base64 representation of signed data: {2}{0}Signature: {3}", Environment.NewLine, @@ -312,7 +307,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { if (key.StartsWith(protocol.openid.Prefix, StringComparison.Ordinal)) { extraSignedParameters.Add(key); } else { - Logger.DebugFormat("The extra parameter '{0}' will not be signed because it does not start with 'openid.'.", key); + Logger.Signatures.DebugFormat("The extra parameter '{0}' will not be signed because it does not start with 'openid.'.", key); } } signedParts = signedParts.Concat(extraSignedParameters); @@ -342,7 +337,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { if (forcePrivateAssociation) { if (!string.IsNullOrEmpty(signedMessage.AssociationHandle)) { - signingLogger.Info("An OpenID 1.x authentication request with a shared association handle will be responded to with a private association in order to provide OP-side replay protection."); + Logger.Signatures.Info("An OpenID 1.x authentication request with a shared association handle will be responded to with a private association in order to provide OP-side replay protection."); } return this.GetDumbAssociationForSigning(); diff --git a/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/AXUtilities.cs b/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/AXUtilities.cs index d19d46e..53b916f 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/AXUtilities.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/AXUtilities.cs @@ -55,7 +55,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange { string countString; if (fields.TryGetValue("count." + alias, out countString)) { if (!int.TryParse(countString, out count) || count <= 0) { - Logger.ErrorFormat("Failed to parse count.{0} value to a positive integer.", alias); + Logger.OpenId.ErrorFormat("Failed to parse count.{0} value to a positive integer.", alias); continue; } countSent = true; @@ -66,7 +66,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange { if (fields.TryGetValue(string.Format(CultureInfo.InvariantCulture, "value.{0}.{1}", alias, i), out value)) { att.Values.Add(value); } else { - Logger.ErrorFormat("Missing value for attribute '{0}'.", att.TypeUri); + Logger.OpenId.ErrorFormat("Missing value for attribute '{0}'.", att.TypeUri); continue; } } @@ -75,7 +75,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange { if (fields.TryGetValue("value." + alias, out value)) { att.Values.Add(value); } else { - Logger.ErrorFormat("Missing value for attribute '{0}'.", att.TypeUri); + Logger.OpenId.ErrorFormat("Missing value for attribute '{0}'.", att.TypeUri); continue; } } @@ -100,7 +100,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange { } string alias = pair.Key.Substring(TypePrefix.Length); if (alias.IndexOfAny(FetchRequest.IllegalAliasCharacters) >= 0) { - Logger.ErrorFormat("Illegal characters in alias name '{0}'.", alias); + Logger.OpenId.ErrorFormat("Illegal characters in alias name '{0}'.", alias); continue; } aliasManager.SetAlias(alias, pair.Value); diff --git a/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/FetchRequest.cs b/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/FetchRequest.cs index 0ba75bb..0f5e4e6 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/FetchRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/FetchRequest.cs @@ -212,7 +212,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange { allAliases.AddRange(requiredAliases); allAliases.AddRange(optionalAliases); if (allAliases.Count == 0) { - Logger.Error("Attribute Exchange extension did not provide any aliases in the if_available or required lists."); + Logger.OpenId.Error("Attribute Exchange extension did not provide any aliases in the if_available or required lists."); return; } @@ -234,7 +234,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange { if (int.TryParse(countString, out count) && count > 0) { att.Count = count; } else { - Logger.Error("count." + alias + " could not be parsed into a positive integer."); + Logger.OpenId.Error("count." + alias + " could not be parsed into a positive integer."); } } } else { @@ -242,7 +242,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange { } this.AddAttribute(att); } else { - Logger.Error("Type URI definition of alias " + alias + " is missing."); + Logger.OpenId.Error("Type URI definition of alias " + alias + " is missing."); } } } @@ -266,19 +266,19 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange { if (this.UpdateUrl != null && !this.UpdateUrl.IsAbsoluteUri) { this.UpdateUrl = null; - Logger.ErrorFormat("The AX fetch request update_url parameter was not absolute ('{0}'). Ignoring value.", this.UpdateUrl); + Logger.OpenId.ErrorFormat("The AX fetch request update_url parameter was not absolute ('{0}'). Ignoring value.", this.UpdateUrl); } if (this.OptionalAliases != null) { if (this.OptionalAliases.IndexOfAny(IllegalAliasListCharacters) >= 0) { - Logger.ErrorFormat("Illegal characters found in Attribute Exchange if_available alias list. Ignoring value."); + Logger.OpenId.ErrorFormat("Illegal characters found in Attribute Exchange if_available alias list. Ignoring value."); this.OptionalAliases = null; } } if (this.RequiredAliases != null) { if (this.RequiredAliases.IndexOfAny(IllegalAliasListCharacters) >= 0) { - Logger.ErrorFormat("Illegal characters found in Attribute Exchange required alias list. Ignoring value."); + Logger.OpenId.ErrorFormat("Illegal characters found in Attribute Exchange required alias list. Ignoring value."); this.RequiredAliases = null; } } diff --git a/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/FetchResponse.cs b/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/FetchResponse.cs index 8395253..c309532 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/FetchResponse.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/FetchResponse.cs @@ -188,7 +188,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange { if (this.UpdateUrl != null && !this.UpdateUrl.IsAbsoluteUri) { this.UpdateUrl = null; - Logger.ErrorFormat("The AX fetch response update_url parameter was not absolute ('{0}'). Ignoring value.", this.UpdateUrl); + Logger.OpenId.ErrorFormat("The AX fetch response update_url parameter was not absolute ('{0}'). Ignoring value.", this.UpdateUrl); } } diff --git a/src/DotNetOpenAuth/OpenId/Extensions/ProviderAuthenticationPolicy/DateTimeEncoder.cs b/src/DotNetOpenAuth/OpenId/Extensions/ProviderAuthenticationPolicy/DateTimeEncoder.cs index ab4afb6..82297d0 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/ProviderAuthenticationPolicy/DateTimeEncoder.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/ProviderAuthenticationPolicy/DateTimeEncoder.cs @@ -58,7 +58,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.ProviderAuthenticationPolicy { if (DateTime.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out dateTime) && dateTime.Kind == DateTimeKind.Utc) { // may be unspecified per our option above return dateTime; } else { - Logger.ErrorFormat("Invalid format for message part: {0}", value); + Logger.OpenId.ErrorFormat("Invalid format for message part: {0}", value); return null; } } diff --git a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs index c8100cf..300827c 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsRequest.cs @@ -275,7 +275,7 @@ TimeZone = '{8}'"; this.TimeZone = requestLevel; break; default: - Logger.WarnFormat("ClaimsRequest.SetProfileRequestFromList: Unrecognized field name '{0}'.", field); + Logger.OpenId.WarnFormat("ClaimsRequest.SetProfileRequestFromList: Unrecognized field name '{0}'.", field); break; } } diff --git a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs index 1d40eec..200a576 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs @@ -134,7 +134,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { if (DateTime.TryParse(value, out newBirthDate)) { this.birthDate = newBirthDate; } else { - Logger.WarnFormat("Simple Registration birthdate '{0}' could not be parsed into a DateTime and may not include month and/or day information. Setting BirthDate property to null.", value); + Logger.OpenId.WarnFormat("Simple Registration birthdate '{0}' could not be parsed into a DateTime and may not include month and/or day information. Setting BirthDate property to null.", value); this.birthDate = null; } } else { diff --git a/src/DotNetOpenAuth/OpenId/Messages/AssociateRequest.cs b/src/DotNetOpenAuth/OpenId/Messages/AssociateRequest.cs index bd37096..f9f638a 100644 --- a/src/DotNetOpenAuth/OpenId/Messages/AssociateRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Messages/AssociateRequest.cs @@ -86,7 +86,7 @@ namespace DotNetOpenAuth.OpenId.Messages { string associationType, sessionType; if (!HmacShaAssociation.TryFindBestAssociation(Protocol.Lookup(provider.ProtocolVersion), true, securityRequirements, useDiffieHellman, out associationType, out sessionType)) { // There are no associations that meet all requirements. - Logger.Warn("Security requirements and protocol combination knock out all possible association types. Dumb mode forced."); + Logger.OpenId.Warn("Security requirements and protocol combination knock out all possible association types. Dumb mode forced."); return null; } @@ -198,14 +198,14 @@ namespace DotNetOpenAuth.OpenId.Messages { ErrorUtilities.VerifyInternal(this.AssociationType != associationType, "The RP asked for an association that should have been allowed, but the OP is trying to suggest the same one as an alternative!"); unsuccessfulResponse.AssociationType = associationType; unsuccessfulResponse.SessionType = sessionType; - Logger.InfoFormat( + Logger.OpenId.InfoFormat( "Association requested of type '{0}' and session '{1}', which the Provider does not support. Sending back suggested alternative of '{0}' with session '{1}'.", this.AssociationType, this.SessionType, unsuccessfulResponse.AssociationType, unsuccessfulResponse.SessionType); } else { - Logger.InfoFormat("Association requested of type '{0}' and session '{1}', which the Provider does not support. No alternative association type qualified for suggesting back to the Relying Party.", this.AssociationType, this.SessionType); + Logger.OpenId.InfoFormat("Association requested of type '{0}' and session '{1}', which the Provider does not support. No alternative association type qualified for suggesting back to the Relying Party.", this.AssociationType, this.SessionType); } return unsuccessfulResponse; diff --git a/src/DotNetOpenAuth/OpenId/OpenIdUtilities.cs b/src/DotNetOpenAuth/OpenId/OpenIdUtilities.cs index e62a483..51368b1 100644 --- a/src/DotNetOpenAuth/OpenId/OpenIdUtilities.cs +++ b/src/DotNetOpenAuth/OpenId/OpenIdUtilities.cs @@ -69,7 +69,7 @@ namespace DotNetOpenAuth.OpenId { } if (value.Contains(" ")) { - Logger.Error("Deserializing a corrupted token. The OpenID Provider may have inappropriately decoded the return_to URL before sending it back to us."); + Logger.OpenId.Error("Deserializing a corrupted token. The OpenID Provider may have inappropriately decoded the return_to URL before sending it back to us."); value = value.Replace(' ', '+'); // Undo any extra decoding the Provider did } diff --git a/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs b/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs index 1d0629a..2433df2 100644 --- a/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs +++ b/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs @@ -50,8 +50,8 @@ namespace DotNetOpenAuth.OpenId { if (endpoints.Count == 0) { endpoints.AddRange(xrds.GenerateClaimedIdentifierServiceEndpoints(claimedIdentifier, userSuppliedIdentifier)); } - Logger.DebugFormat("Total services discovered in XRDS: {0}", endpoints.Count); - Logger.Debug(endpoints.ToStringDeferred(true)); + Logger.Yadis.DebugFormat("Total services discovered in XRDS: {0}", endpoints.Count); + Logger.Yadis.Debug(endpoints.ToStringDeferred(true)); return endpoints; } @@ -74,8 +74,8 @@ namespace DotNetOpenAuth.OpenId { if (endpoints.Count == 0) { endpoints.AddRange(xrds.GenerateClaimedIdentifierServiceEndpoints(userSuppliedIdentifier)); } - Logger.DebugFormat("Total services discovered in XRDS: {0}", endpoints.Count); - Logger.Debug(endpoints.ToStringDeferred(true)); + Logger.Yadis.DebugFormat("Total services discovered in XRDS: {0}", endpoints.Count); + Logger.Yadis.Debug(endpoints.ToStringDeferred(true)); return endpoints; } @@ -126,7 +126,7 @@ namespace DotNetOpenAuth.OpenId { foreach (var uri in service.UriElements) { // spec section 7.3.2.3 on Claimed Id -> CanonicalID substitution if (service.Xrd.CanonicalID == null) { - Logger.WarnFormat(XrdsStrings.MissingCanonicalIDElement, userSuppliedIdentifier); + Logger.Yadis.WarnFormat(XrdsStrings.MissingCanonicalIDElement, userSuppliedIdentifier); break; // skip on to next service } ErrorUtilities.VerifyProtocol(service.Xrd.IsCanonicalIdVerified, XrdsStrings.CIDVerificationFailed, userSuppliedIdentifier); diff --git a/src/DotNetOpenAuth/OpenId/Provider/AuthenticationRequest.cs b/src/DotNetOpenAuth/OpenId/Provider/AuthenticationRequest.cs index fba41f4..34ade49 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/AuthenticationRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/AuthenticationRequest.cs @@ -256,7 +256,7 @@ namespace DotNetOpenAuth.OpenId.Provider { // The spec requires that the return_to URLs given in an RPs XRDS doc // do not contain wildcards. if (discoveredReturnToUrl.DomainWildcard) { - Logger.WarnFormat("Realm {0} contained return_to URL {1} which contains a wildcard, which is not allowed.", Realm, discoveredReturnToUrl); + Logger.Yadis.WarnFormat("Realm {0} contained return_to URL {1} which contains a wildcard, which is not allowed.", Realm, discoveredReturnToUrl); continue; } @@ -269,10 +269,10 @@ namespace DotNetOpenAuth.OpenId.Provider { } } catch (ProtocolException ex) { // Don't do anything else. We quietly fail at return_to verification and return false. - Logger.InfoFormat("Relying party discovery at URL {0} failed. {1}", Realm, ex); + Logger.Yadis.InfoFormat("Relying party discovery at URL {0} failed. {1}", Realm, ex); } catch (WebException ex) { // Don't do anything else. We quietly fail at return_to verification and return false. - Logger.InfoFormat("Relying party discovery at URL {0} failed. {1}", Realm, ex); + Logger.Yadis.InfoFormat("Relying party discovery at URL {0} failed. {1}", Realm, ex); } return false; diff --git a/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs b/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs index e46fc9b..ee4d6cb 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs @@ -319,7 +319,7 @@ namespace DotNetOpenAuth.OpenId.Provider { var serviceEndpoint = DotNetOpenAuth.OpenId.RelyingParty.ServiceEndpoint.CreateForClaimedIdentifier(claimedIdentifier, localIdentifier, new ProviderEndpointDescription(providerEndpoint, Protocol.Default.Version), null, null); var discoveredEndpoints = claimedIdentifier.Discover(this.WebRequestHandler); if (!discoveredEndpoints.Contains(serviceEndpoint)) { - Logger.DebugFormat( + Logger.OpenId.DebugFormat( "Failed to send unsolicited assertion for {0} because its discovered services did not include this endpoint. This endpoint: {1}{2} Discovered endpoints: {1}{3}", claimedIdentifier, Environment.NewLine, @@ -328,7 +328,7 @@ namespace DotNetOpenAuth.OpenId.Provider { ErrorUtilities.ThrowProtocol(OpenIdStrings.UnsolicitedAssertionForUnrelatedClaimedIdentifier, claimedIdentifier); } - Logger.InfoFormat("Preparing unsolicited assertion for {0}", claimedIdentifier); + Logger.OpenId.InfoFormat("Preparing unsolicited assertion for {0}", claimedIdentifier); var returnToEndpoint = relyingParty.Discover(this.WebRequestHandler, true).FirstOrDefault(); ErrorUtilities.VerifyProtocol(returnToEndpoint != null, OpenIdStrings.NoRelyingPartyEndpointDiscovered, relyingParty); @@ -388,7 +388,7 @@ namespace DotNetOpenAuth.OpenId.Provider { ErrorUtilities.VerifyArgumentNotNull(ex, "ex"); ErrorUtilities.VerifyArgumentNotNull(httpRequestInfo, "httpRequestInfo"); - Logger.Error("An exception was generated while processing an incoming OpenID request.", ex); + Logger.OpenId.Error("An exception was generated while processing an incoming OpenID request.", ex); IErrorMessage errorMessage; // We must create the appropriate error message type (direct vs. indirect) diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/AssociationManager.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/AssociationManager.cs index 8d4de66..a37c8c7 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/AssociationManager.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/AssociationManager.cs @@ -181,17 +181,17 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { return association; } else if (associateUnsuccessfulResponse != null) { if (string.IsNullOrEmpty(associateUnsuccessfulResponse.AssociationType)) { - Logger.Debug("Provider rejected an association request and gave no suggestion as to an alternative association type. Giving up."); + Logger.OpenId.Debug("Provider rejected an association request and gave no suggestion as to an alternative association type. Giving up."); return null; } if (!this.securitySettings.IsAssociationInPermittedRange(Protocol.Lookup(provider.ProtocolVersion), associateUnsuccessfulResponse.AssociationType)) { - Logger.DebugFormat("Provider rejected an association request and suggested '{0}' as an association to try, which this Relying Party does not support. Giving up.", associateUnsuccessfulResponse.AssociationType); + Logger.OpenId.DebugFormat("Provider rejected an association request and suggested '{0}' as an association to try, which this Relying Party does not support. Giving up.", associateUnsuccessfulResponse.AssociationType); return null; } if (retriesRemaining <= 0) { - Logger.Debug("Unable to agree on an association type with the Provider in the allowed number of retries. Giving up."); + Logger.OpenId.Debug("Unable to agree on an association type with the Provider in the allowed number of retries. Giving up."); return null; } @@ -211,7 +211,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } catch (ProtocolException ex) { // Since having associations with OPs is not totally critical, we'll log and eat // the exception so that auth may continue in dumb mode. - Logger.ErrorFormat("An error occurred while trying to create an association with {0}. {1}", provider.Endpoint, ex); + Logger.OpenId.ErrorFormat("An error occurred while trying to create an association with {0}. {1}", provider.Endpoint, ex); return null; } } diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs index 5a28fad..2e22aec 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs @@ -260,11 +260,11 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { userSuppliedIdentifier.TryRequireSsl(out userSuppliedIdentifier); } - if (Logger.IsWarnEnabled && returnToUrl.Query != null) { + if (Logger.OpenId.IsWarnEnabled && returnToUrl.Query != null) { NameValueCollection returnToArgs = HttpUtility.ParseQueryString(returnToUrl.Query); foreach (string key in returnToArgs) { if (OpenIdRelyingParty.IsOpenIdSupportingParameter(key)) { - Logger.WarnFormat("OpenID argument \"{0}\" found in return_to URL. This can corrupt an OpenID response.", key); + Logger.OpenId.WarnFormat("OpenID argument \"{0}\" found in return_to URL. This can corrupt an OpenID response.", key); } } } @@ -279,7 +279,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { try { serviceEndpoints = userSuppliedIdentifier.Discover(relyingParty.WebRequestHandler); } catch (ProtocolException ex) { - Logger.ErrorFormat("Error while performing discovery on: \"{0}\": {1}", userSuppliedIdentifier, ex); + Logger.Yadis.ErrorFormat("Error while performing discovery on: \"{0}\": {1}", userSuppliedIdentifier, ex); serviceEndpoints = EmptyList<ServiceEndpoint>.Instance; } @@ -304,7 +304,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// before calling this method. /// </remarks> private static IEnumerable<AuthenticationRequest> CreateInternal(Identifier userSuppliedIdentifier, OpenIdRelyingParty relyingParty, Realm realm, Uri returnToUrl, IEnumerable<ServiceEndpoint> serviceEndpoints, bool createNewAssociationsAsNeeded) { - Logger.InfoFormat("Performing discovery on user-supplied identifier: {0}", userSuppliedIdentifier); + Logger.Yadis.InfoFormat("Performing discovery on user-supplied identifier: {0}", userSuppliedIdentifier); IEnumerable<ServiceEndpoint> endpoints = FilterAndSortEndpoints(serviceEndpoints, relyingParty); // Maintain a list of endpoints that we could not form an association with. @@ -313,9 +313,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { var failedAssociationEndpoints = new List<ServiceEndpoint>(0); foreach (var endpoint in endpoints) { - Logger.InfoFormat("Creating authentication request for user supplied Identifier: {0}", userSuppliedIdentifier); - Logger.DebugFormat("Realm: {0}", realm); - Logger.DebugFormat("Return To: {0}", returnToUrl); + Logger.OpenId.InfoFormat("Creating authentication request for user supplied Identifier: {0}", userSuppliedIdentifier); // The strategy here is to prefer endpoints with whom we can create associations. Association association = null; @@ -325,7 +323,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { // associations where they are already formed from previous authentications. association = createNewAssociationsAsNeeded ? relyingParty.AssociationManager.GetOrCreateAssociation(endpoint.ProviderDescription) : relyingParty.AssociationManager.GetExistingAssociation(endpoint.ProviderDescription); if (association == null && createNewAssociationsAsNeeded) { - Logger.WarnFormat("Failed to create association with {0}. Skipping to next endpoint.", endpoint.ProviderEndpoint); + Logger.OpenId.WarnFormat("Failed to create association with {0}. Skipping to next endpoint.", endpoint.ProviderEndpoint); // No association could be created. Add it to the list of failed association // endpoints and skip to the next available endpoint. @@ -341,12 +339,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { // since we apparently are still running, the caller must want another request. // We'll go ahead and generate the requests to OPs that may be down. if (failedAssociationEndpoints.Count > 0) { - Logger.WarnFormat("Now generating requests for Provider endpoints that failed initial association attempts."); + Logger.OpenId.WarnFormat("Now generating requests for Provider endpoints that failed initial association attempts."); foreach (var endpoint in failedAssociationEndpoints) { - Logger.WarnFormat("Creating authentication request for user supplied Identifier: {0}", userSuppliedIdentifier); - Logger.DebugFormat("Realm: {0}", realm); - Logger.DebugFormat("Return To: {0}", returnToUrl); + Logger.OpenId.WarnFormat("Creating authentication request for user supplied Identifier: {0}", userSuppliedIdentifier); // Create the auth request, but prevent it from attempting to create an association // because we've already tried. Let's not have it waste time trying again. @@ -390,14 +386,14 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } if (anyFilteredOut) { - Logger.DebugFormat("Some endpoints were filtered out. Total endpoints remaining: {0}", filteredEndpoints.Count); + Logger.Yadis.DebugFormat("Some endpoints were filtered out. Total endpoints remaining: {0}", filteredEndpoints.Count); } - if (Logger.IsDebugEnabled) { + if (Logger.Yadis.IsDebugEnabled) { if (MessagingUtilities.AreEquivalent(endpoints, endpointList)) { - Logger.Debug("Filtering and sorting of endpoints did not affect the list."); + Logger.Yadis.Debug("Filtering and sorting of endpoints did not affect the list."); } else { - Logger.Debug("After filtering and sorting service endpoints, this is the new prioritized list:"); - Logger.Debug(Util.ToStringDeferred(filteredEndpoints, true)); + Logger.Yadis.Debug("After filtering and sorting service endpoints, this is the new prioritized list:"); + Logger.Yadis.Debug(Util.ToStringDeferred(filteredEndpoints, true)); } } diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs index 896c88b..7beb110 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs @@ -795,7 +795,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { private static TimeSpan TimeoutDefault { get { if (Debugger.IsAttached) { - Logger.Warn("Debugger is attached. Inflating default OpenIdAjaxTextbox.Timeout value to infinity."); + Logger.OpenId.Warn("Debugger is attached. Inflating default OpenIdAjaxTextbox.Timeout value to infinity."); return TimeSpan.MaxValue; } else { return TimeSpan.FromSeconds(8); @@ -886,7 +886,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { string userSuppliedIdentifier = eventArgument; ErrorUtilities.VerifyNonZeroLength(userSuppliedIdentifier, "userSuppliedIdentifier"); - Logger.InfoFormat("AJAX discovery on {0} requested.", userSuppliedIdentifier); + Logger.OpenId.InfoFormat("AJAX discovery on {0} requested.", userSuppliedIdentifier); // We prepare a JSON object with this interface: // class jsonResponse { @@ -1130,7 +1130,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// parameters. (i.e. "callback('arg1', 2)"). No escaping is done by this method.</param> /// <param name="preAssignments">An optional list of assignments to make to the input box object before placing the method call.</param> private void CallbackUserAgentMethod(string methodCall, string[] preAssignments) { - Logger.InfoFormat("Sending Javascript callback: {0}", methodCall); + Logger.OpenId.InfoFormat("Sending Javascript callback: {0}", methodCall); Page.Response.Write(@"<html><body><script language='javascript'> var inPopup = !window.frameElement; var objSrc = inPopup ? window.opener.waiting_openidBox : window.frameElement.openidBox; @@ -1287,7 +1287,7 @@ if (!openidbox.dnoi_internal.onSubmit()) {{ return false; }} /// Notifies the user agent via an AJAX response of a completed authentication attempt. /// </summary> private void ReportAuthenticationResult() { - Logger.InfoFormat("AJAX (iframe) callback from OP: {0}", this.Page.Request.Url); + Logger.OpenId.InfoFormat("AJAX (iframe) callback from OP: {0}", this.Page.Request.Url); List<string> assignments = new List<string>(); var authResponse = this.RelyingPartyNonVerifying.GetResponse(); diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdMobileTextBox.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdMobileTextBox.cs index cf867b7..2e31838 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdMobileTextBox.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdMobileTextBox.cs @@ -585,7 +585,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { // Add state that needs to survive across the redirect. this.Request.AddCallbackArguments(UsePersistentCookieCallbackKey, this.UsePersistentCookie.ToString(CultureInfo.InvariantCulture)); } else { - Logger.WarnFormat("An invalid identifier was entered ({0}), but not caught by any validation routine.", this.Text); + Logger.OpenId.WarnFormat("An invalid identifier was entered ({0}), but not caught by any validation routine.", this.Text); this.Request = null; } } catch (ProtocolException ex) { diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs index 87e1112..9afa9ff 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs @@ -339,7 +339,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } else if ((negativeAssertion = message as NegativeAssertionResponse) != null) { return new NegativeAuthenticationResponse(negativeAssertion); } else if (message != null) { - Logger.WarnFormat("Received unexpected message type {0} when expecting an assertion message.", message.GetType().Name); + Logger.OpenId.WarnFormat("Received unexpected message type {0} when expecting an assertion message.", message.GetType().Name); } return null; diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdTextBox.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdTextBox.cs index 97bca99..95511c5 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdTextBox.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdTextBox.cs @@ -910,7 +910,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { this.Request.AddCallbackArguments(UsePersistentCookieCallbackKey, this.UsePersistentCookie.ToString(CultureInfo.InvariantCulture)); } } else { - Logger.WarnFormat("An invalid identifier was entered ({0}), but not caught by any validation routine.", this.Text); + Logger.OpenId.WarnFormat("An invalid identifier was entered ({0}), but not caught by any validation routine.", this.Text); this.Request = null; } } diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs index 8d71fc6..b62a7c8 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs @@ -238,7 +238,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// an attempt by someone to spoof another user's identity with a rogue Provider. /// </exception> private void VerifyDiscoveryMatchesAssertion() { - Logger.Debug("Verifying assertion matches identifier discovery results..."); + Logger.OpenId.Debug("Verifying assertion matches identifier discovery results..."); // While it LOOKS like we're performing discovery over HTTP again // Yadis.IdentifierDiscoveryCachePolicy is set to HttpRequestCacheLevel.CacheIfAvailable diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/PrivateSecretManager.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/PrivateSecretManager.cs index 09eea16..0895d77 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/PrivateSecretManager.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/PrivateSecretManager.cs @@ -106,7 +106,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { byte[] secret = MessagingUtilities.GetCryptoRandomData(secretLength); privateAssociation = HmacShaAssociation.Create(CreateNewAssociationHandle(), secret, this.securitySettings.PrivateSecretMaximumAge); if (!privateAssociation.HasUsefulLifeRemaining) { - Logger.WarnFormat( + Logger.OpenId.WarnFormat( "Brand new private association has a shorter lifespan ({0}) than the maximum allowed authentication time for a user ({1}). This may lead to login failures.", this.securitySettings.PrivateSecretMaximumAge, DotNetOpenAuthSection.Configuration.OpenId.MaxAuthenticationTime); diff --git a/src/DotNetOpenAuth/OpenId/UriIdentifier.cs b/src/DotNetOpenAuth/OpenId/UriIdentifier.cs index 56d53f4..615dc9c 100644 --- a/src/DotNetOpenAuth/OpenId/UriIdentifier.cs +++ b/src/DotNetOpenAuth/OpenId/UriIdentifier.cs @@ -229,17 +229,17 @@ namespace DotNetOpenAuth.OpenId { if (endpoints.Count == 0) { var htmlEndpoints = new List<ServiceEndpoint>(DiscoverFromHtml(yadisResult.NormalizedUri, this, yadisResult.ResponseText)); if (htmlEndpoints.Any()) { - Logger.DebugFormat("Total services discovered in HTML: {0}", htmlEndpoints.Count); - Logger.Debug(htmlEndpoints.ToStringDeferred(true)); + Logger.Yadis.DebugFormat("Total services discovered in HTML: {0}", htmlEndpoints.Count); + Logger.Yadis.Debug(htmlEndpoints.ToStringDeferred(true)); endpoints.AddRange(htmlEndpoints.Where(ep => !IsDiscoverySecureEndToEnd || ep.IsSecure)); if (endpoints.Count == 0) { - Logger.Info("No HTML discovered endpoints met the security requirements."); + Logger.Yadis.Info("No HTML discovered endpoints met the security requirements."); } } else { - Logger.Debug("HTML discovery failed to find any endpoints."); + Logger.Yadis.Debug("HTML discovery failed to find any endpoints."); } } else { - Logger.Debug("Skipping HTML discovery because XRDS contained service endpoints."); + Logger.Yadis.Debug("Skipping HTML discovery because XRDS contained service endpoints."); } } return endpoints; @@ -338,7 +338,7 @@ namespace DotNetOpenAuth.OpenId { if (Identifier.IsValid(delegateLinkTag.Href)) { providerLocalIdentifier = delegateLinkTag.Href; } else { - Logger.WarnFormat("Skipping endpoint data because local id is badly formed ({0}).", delegateLinkTag.Href); + Logger.Yadis.WarnFormat("Skipping endpoint data because local id is badly formed ({0}).", delegateLinkTag.Href); continue; // skip to next version } } diff --git a/src/DotNetOpenAuth/Yadis/Yadis.cs b/src/DotNetOpenAuth/Yadis/Yadis.cs index 84443e4..c3ae307 100644 --- a/src/DotNetOpenAuth/Yadis/Yadis.cs +++ b/src/DotNetOpenAuth/Yadis/Yadis.cs @@ -51,46 +51,46 @@ namespace DotNetOpenAuth.Yadis { CachedDirectWebResponse response; try { if (requireSsl && !string.Equals(uri.Uri.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { - Logger.WarnFormat("Discovery on insecure identifier '{0}' aborted.", uri); + Logger.Yadis.WarnFormat("Discovery on insecure identifier '{0}' aborted.", uri); return null; } response = Request(requestHandler, uri, requireSsl, ContentTypes.Html, ContentTypes.XHtml, ContentTypes.Xrds).GetSnapshot(MaximumResultToScan); if (response.Status != System.Net.HttpStatusCode.OK) { - Logger.ErrorFormat("HTTP error {0} {1} while performing discovery on {2}.", (int)response.Status, response.Status, uri); + Logger.Yadis.ErrorFormat("HTTP error {0} {1} while performing discovery on {2}.", (int)response.Status, response.Status, uri); return null; } } catch (ArgumentException ex) { // Unsafe URLs generate this - Logger.WarnFormat("Unsafe OpenId URL detected ({0}). Request aborted. {1}", uri, ex); + Logger.Yadis.WarnFormat("Unsafe OpenId URL detected ({0}). Request aborted. {1}", uri, ex); return null; } CachedDirectWebResponse response2 = null; if (IsXrdsDocument(response)) { - Logger.Debug("An XRDS response was received from GET at user-supplied identifier."); + Logger.Yadis.Debug("An XRDS response was received from GET at user-supplied identifier."); response2 = response; } else { string uriString = response.Headers.Get(HeaderName); Uri url = null; if (uriString != null) { if (Uri.TryCreate(uriString, UriKind.Absolute, out url)) { - Logger.DebugFormat("{0} found in HTTP header. Preparing to pull XRDS from {1}", HeaderName, url); + Logger.Yadis.DebugFormat("{0} found in HTTP header. Preparing to pull XRDS from {1}", HeaderName, url); } } if (url == null && response.ContentType.MediaType == ContentTypes.Html) { url = FindYadisDocumentLocationInHtmlMetaTags(response.GetResponseString()); if (url != null) { - Logger.DebugFormat("{0} found in HTML Http-Equiv tag. Preparing to pull XRDS from {1}", HeaderName, url); + Logger.Yadis.DebugFormat("{0} found in HTML Http-Equiv tag. Preparing to pull XRDS from {1}", HeaderName, url); } } if (url != null) { if (!requireSsl || string.Equals(url.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { response2 = Request(requestHandler, url, requireSsl, ContentTypes.Xrds).GetSnapshot(MaximumResultToScan); if (response2.Status != HttpStatusCode.OK) { - Logger.ErrorFormat("HTTP error {0} {1} while performing discovery on {2}.", (int)response2.Status, response2.Status, uri); + Logger.Yadis.ErrorFormat("HTTP error {0} {1} while performing discovery on {2}.", (int)response2.Status, response2.Status, uri); return null; } } else { - Logger.WarnFormat("XRDS document at insecure location '{0}'. Aborting YADIS discovery.", url); + Logger.Yadis.WarnFormat("XRDS document at insecure location '{0}'. Aborting YADIS discovery.", url); } } } |