public void Format_LogLevelExamples_ProducesExpectedOutput(LogLevel logLevel, string expected)
        {
            var formatter = new TextLogFormatter(_Clock, _SystemTimeZone);

            List <string> output = formatter.Format(logLevel, "DUMMY").ToList();

            CollectionAssert.AreEqual(new[] { expected }, output);
        }
        public void Format_MultiLineInput_ProducesExpectedOutput()
        {
            var formatter = new TextLogFormatter(_Clock, _SystemTimeZone);

            var           input  = "Line 1" + Environment.NewLine + "Line 2";
            List <string> output = formatter.Format(LogLevel.Debug, input).ToList();

            CollectionAssert.AreEqual(
                new[] { "2018-01-01 00:00:00.000 DEBUG: Line 1", "2018-01-01 00:00:01.000 DEBUG: Line 2" }, output);
        }
Example #3
0
    public FileLogWriter(string path, Encoding encoding, bool async, int bufferSize, TimeSpan timerPeriod, bool autoFlush, FileAttributes fileAttributes,
                         DateTimeKind dateTimeKind)
    {
        _async = async;
        ILogFormatter formatter = new TextLogFormatter();

        // ILogFormatter formatter = new XmlLogFormatter();

        if (async)
        {
            _logFile = new AsyncLogFile(path, encoding, bufferSize, timerPeriod, formatter, fileAttributes, dateTimeKind);
        }
        else
        {
            _logFile = new LogFile(path, encoding, bufferSize, autoFlush, formatter, fileAttributes, dateTimeKind);
        }
    }