Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestLogger"/> class.
        /// Creates a new instance of the <see cref="TestLogger" /> class.
        /// </summary>
        /// <param name="name">The name of the logger.</param>
        /// <param name="output">The test output helper.</param>
        /// <param name="settings">Optional logging settings.</param>
        /// <exception cref="ArgumentException">The <paramref name="name" /> is <c>null</c>, empty or whitespace.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="output" /> is <c>null</c>.</exception>
        public TestLogger(string name, ITestOutputHelper output, LoggingSettings settings = null)
        {
            EnsureArg.IsNotNullOrWhiteSpace(name, nameof(name));
            EnsureArg.IsNotNull(output, nameof(output));

            this.name      = name;
            this.output    = output;
            this.settings  = settings ?? new LoggingSettings();
            this.formatter = this.settings.Formatter ?? new DefaultLogFormatter(this.settings);
            this.scopes    = new Stack <LoggingScopeWriter>();
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultLogFormatter"/> class.
        /// </summary>
        /// <param name="settings">The logging settings.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="settings"/> value is <c>null</c>.</exception>
        public DefaultLogFormatter(LoggingSettings settings)
        {
            EnsureArg.IsNotNull(settings, nameof(settings));

            this.settings = settings;
        }