/// <summary> /// Creates a new logging adapter that writes to the specified logging bus. /// </summary> /// <param name="loggingBus">The bus on which this logger writes.</param> /// <param name="logSourceObj">The source that produces the log events.</param> /// <param name="logMessageFormatter">The formatter used to format log messages.</param> /// <returns>The newly created logging adapter.</returns> public static ILoggingAdapter GetLogger(LoggingBus loggingBus, object logSourceObj, ILogMessageFormatter logMessageFormatter = null) { //TODO: refine this string logSource; Type logClass; if (logSourceObj is string) { logSource = (string)logSourceObj; logClass = typeof(DummyClassForStringSources); } else { logSource = logSourceObj.ToString(); if (logSourceObj is Type) { logClass = (Type)logSourceObj; } else { logClass = logSourceObj.GetType(); } } return(new BusLogging(loggingBus, logSource, logClass, logMessageFormatter ?? new DefaultLogMessageFormatter())); }
public static LoggingAdapter GetLogger(LoggingBus loggingBus, object logSourceObj) { //TODO: refine this string logSource; Type logClass; if (logSourceObj is string) { logSource = (string)logSourceObj; logClass = typeof(DummyClassForStringSources); } else { logSource = logSourceObj.ToString(); if (logSourceObj is Type) { logClass = (Type)logSourceObj; } else { logClass = logSourceObj.GetType(); } } return(new BusLogging(loggingBus, logSource, logClass)); }
/// <summary> /// Initializes a new instance of the <see cref="BusLogging" /> class. /// </summary> /// <param name="bus">The bus.</param> /// <param name="logSource">The log source.</param> /// <param name="logClass">The log class.</param> public BusLogging(LoggingBus bus, string logSource, Type logClass) { this.bus = bus; this.logSource = logSource; this.logClass = logClass; isErrorEnabled = bus.LogLevel <= LogLevel.ErrorLevel; isWarningEnabled = bus.LogLevel <= LogLevel.WarningLevel; isInfoEnabled = bus.LogLevel <= LogLevel.InfoLevel; isDebugEnabled = bus.LogLevel <= LogLevel.DebugLevel; }
/// <summary> /// Initializes a new instance of the <see cref="BusLogging" /> class. /// </summary> /// <param name="bus">The logging bus instance that messages will be published to.</param> /// <param name="logSource">The log source.</param> /// <param name="logClass">The log class.</param> /// <param name="logMessageFormatter">The log message formatter.</param> public BusLogging(LoggingBus bus, string logSource, Type logClass, ILogMessageFormatter logMessageFormatter) : base(logMessageFormatter) { _bus = bus; _logSource = logSource; _logClass = logClass; _isErrorEnabled = bus.LogLevel <= LogLevel.ErrorLevel; _isWarningEnabled = bus.LogLevel <= LogLevel.WarningLevel; _isInfoEnabled = bus.LogLevel <= LogLevel.InfoLevel; _isDebugEnabled = bus.LogLevel <= LogLevel.DebugLevel; }
/// <summary> /// Initializes a new instance of the <see cref="InitializeLogger" /> message. /// </summary> /// <param name="loggingBus">The bus used by the logger to log events.</param> public InitializeLogger(LoggingBus loggingBus) { LoggingBus = loggingBus; }
/// <summary> /// Creates a new logging adapter that writes to the specified logging bus. /// </summary> /// <param name="loggingBus">The bus on which this logger writes.</param> /// <param name="logSourceObj">The source that produces the log events.</param> /// <param name="logMessageFormatter">The formatter used to format log messages.</param> /// <returns>The newly created logging adapter.</returns> public static ILoggingAdapter GetLogger(LoggingBus loggingBus, object logSourceObj, ILogMessageFormatter logMessageFormatter = null) { var logSource = LogSource.Create(logSourceObj); return(new BusLogging(loggingBus, logSource.Source, logSource.Type, logMessageFormatter ?? new DefaultLogMessageFormatter())); }