Пример #1
0
        public void BasicTest()
        {
            var utcDateTime = new DateTime(1980, 8, 1, 10, 15, 0, DateTimeKind.Utc);
            var formatter   = new DateTimeFormatter(universalTime: true);

            Assert.Equal("01.08.1980 10:15:00.000", formatter.WriteToString(utcDateTime));

            formatter.FormatProvider = CultureInfo.InvariantCulture;
            formatter.Format         = "f";
            Assert.Equal("Friday, 01 August 1980 10:15", formatter.WriteToString(utcDateTime));

            formatter.Format = "HH:ss";
            Assert.Matches(@"\d{2}:\d{2}", formatter.WriteToString());
        }
Пример #2
0
        protected override void OnLog(LogEventArgs itm)
        {
            var createdAt = DateTimeFormatter.WriteToString(itm.CreatedAtUtc);
            var level     = LogLevelFormatter.WriteToString(itm.Level);

            Console.WriteLine($"{createdAt} {level}: {itm.Message}");
        }
Пример #3
0
 protected override void OnLog(LogEventArgs itm)
 {
     lock (SyncLock)
     {
         var createdAt = DateTimeFormatter.WriteToString(itm.CreatedAtUtc);
         var level     = LogLevelFormatter.WriteToString(itm.Level);
         _outputStream.WriteLine($"{createdAt} {level} {itm.Message}");
     }
 }
Пример #4
0
        protected override void OnLog(LogEventArgs itm)
        {
            var createdAt = DateTimeFormatter.WriteToString(itm.CreatedAtUtc);
            var level     = LogLevelFormatter.WriteToString(itm.Level);

            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write(createdAt);
            Console.Write(' ');
            var levelColor = GetLevelColor(itm.Level);

            Console.ForegroundColor = levelColor;
            Console.Write(level);
            Console.Write(": ");
            Console.ResetColor();
            Console.WriteLine(itm.Message);
        }