//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth {
using System;
using System.Globalization;
using DotNetOpenAuth.Logging;
using DotNetOpenAuth.Logging.LogProviders;
using DotNetOpenAuth.Messaging;
using Validation;
///
/// A general logger for the entire DotNetOpenAuth library.
///
///
/// Because this logger is intended for use with non-localized strings, the
/// overloads that take have been removed, and
/// is used implicitly.
///
internal static partial class Logger {
#region Category-specific loggers
///
/// The instance that is to be used
/// by this static Logger for the duration of the appdomain.
///
private static readonly ILog library = CreateWithBanner("DotNetOpenAuth");
///
/// Backing field for the property.
///
private static readonly ILog yadis = Create("DotNetOpenAuth.Yadis");
///
/// Backing field for the property.
///
private static readonly ILog messaging = Create("DotNetOpenAuth.Messaging");
///
/// Backing field for the property.
///
private static readonly ILog channel = Create("DotNetOpenAuth.Messaging.Channel");
///
/// Backing field for the property.
///
private static readonly ILog bindings = Create("DotNetOpenAuth.Messaging.Bindings");
///
/// Backing field for the property.
///
private static readonly ILog signatures = Create("DotNetOpenAuth.Messaging.Bindings.Signatures");
///
/// Backing field for the property.
///
private static readonly ILog http = Create("DotNetOpenAuth.Http");
///
/// Backing field for the property.
///
private static readonly ILog controls = Create("DotNetOpenAuth.Controls");
///
/// Backing field for the property.
///
private static readonly ILog openId = Create("DotNetOpenAuth.OpenId");
///
/// Backing field for the property.
///
private static readonly ILog oauth = Create("DotNetOpenAuth.OAuth");
///
/// Gets the logger for general library logging.
///
internal static ILog Library { get { return library; } }
///
/// Gets the logger for service discovery and selection events.
///
internal static ILog Yadis { get { return yadis; } }
///
/// Gets the logger for Messaging events.
///
internal static ILog Messaging { get { return messaging; } }
///
/// Gets the logger for Channel events.
///
internal static ILog Channel { get { return channel; } }
///
/// Gets the logger for binding elements and binding-element related events on the channel.
///
internal static ILog Bindings { get { return bindings; } }
///
/// Gets the logger specifically used for logging verbose text on everything about the signing process.
///
internal static ILog Signatures { get { return signatures; } }
///
/// Gets the logger for HTTP-level events.
///
internal static ILog Http { get { return http; } }
///
/// Gets the logger for events logged by ASP.NET controls.
///
internal static ILog Controls { get { return controls; } }
///
/// Gets the logger for high-level OpenID events.
///
internal static ILog OpenId { get { return openId; } }
///
/// Gets the logger for high-level OAuth events.
///
internal static ILog OAuth { get { return oauth; } }
#endregion
///
/// Creates an additional logger on demand for a subsection of the application.
///
/// A name that will be included in the log file.
/// The instance created with the given name.
internal static ILog Create(string name) {
Requires.NotNullOrEmpty(name, "name");
return InitializeFacade(name);
}
///
/// Creates the main logger for the library, and emits an INFO message
/// that is the name and version of the library.
///
/// A name that will be included in the log file.
/// The instance created with the given name.
internal static ILog CreateWithBanner(string name) {
Requires.NotNullOrEmpty(name, "name");
ILog log = Create(name);
log.Info(Util.LibraryVersion);
return log;
}
///
/// Creates an additional logger on demand for a subsection of the application.
///
/// A type whose full name that will be included in the log file.
/// The instance created with the given type name.
internal static ILog Create(Type type) {
Requires.NotNull(type, "type");
return Create(type.FullName);
}
///
/// Discovers the presence of Log4net.dll and other logging mechanisms
/// and returns the best available logger.
///
/// The name of the log to initialize.
/// The instance of the logger to use.
private static ILog InitializeFacade(string name) {
return LogProvider.GetLogger(name);
}
}
}