/// <summary> /// Initializes a new instance of the <see cref="Logger"/> class. /// </summary> /// <param name="logItemHandler">Optional <see cref="LogItemHandler" /> to process <see cref="LogItem" />'s; DEFAULT is a null handler.</param> /// <param name="correlationManager">Optional correlation manager potentially with active correlations; DEFAULT is a new <see cref="CorrelationManager" />.</param> /// <param name="defaultOrigin">Optional default origin to use; DEFAULT is <see cref="LogItemOrigin.NaosLoggingLogger" />.</param> /// <param name="defaultComment">Optional default comment to use; DEFAULT is null.</param> public Logger(LogItemHandler logItemHandler = null, IManageCorrelations correlationManager = null, string defaultOrigin = null, string defaultComment = null) { this.defaultComment = defaultComment; this.defaultOrigin = defaultOrigin ?? LogItemOrigin.NaosLoggingLogger.ToString(); this.logItemHandler = logItemHandler ?? DefaultLogItemHandler; this.correlationManager = correlationManager ?? new CorrelationManager(); }
/// <inheritdoc /> public void SetCallback(LogItemHandler callback) { lock (this.syncSetHandler) { this.logItemHandler = callback; } }
/// <summary> /// Initializes a new instance of the <see cref="UsingBlockLogger"/> class. /// </summary> /// <param name="correlationManager">Optional correlation manager potentially with active correlations; DEFAULT is a new <see cref="CorrelationManager" />.</param> /// <param name="logItemHandler">Handler callback to log send generated messages to.</param> /// <param name="origin">Origin override.</param> /// <param name="initialComment">Comment for first and last message.</param> public UsingBlockLogger( IManageCorrelations correlationManager, LogItemHandler logItemHandler, string origin, string initialComment) : base(logItemHandler, correlationManager, origin, initialComment) { this.Write(() => InitialItemOfUsingBlockSubject); }
/// <summary> /// Set the <see cref="LogItemHandler" /> to send logged messages to. /// </summary> /// <param name="callback">Call back to send messages to.</param> public static void SetCallback(LogItemHandler callback) { Instance.SetCallback(callback); }