示例#1
0
 /// <summary>
 /// Converts message to number of log params.
 /// </summary>
 /// <param name="message">Message.</param>
 /// <returns>Returns params.</returns>
 private Task <object[]> GetParamsAsync(IWavesMessageObject message)
 {
     return(Task.FromResult(new object[]
     {
         $"{message.DateTime.ToShortDateString()} {message.DateTime.ToShortTimeString()}",
         $"[{message.Type.ToDescription()}]",
         message.Sender,
         message.ToString(),
     }));
 }
示例#2
0
        /// <inheritdoc />
        public override Task WriteLogAsync(IWavesMessageObject message)
        {
            var label      = message.Type.ToDescription();
            var labelColor = Colors.GetColor(message.Type);
            var sender     = message.Sender?.ToString();

            if (message.Sender == null)
            {
                sender = "Logger";
            }

            System.Console.WriteLine(
                "[{0}] [{1}]\t{2}: {3}",
                message.DateTime
                .ToString(CultureInfo.CurrentCulture)
                .Pastel(Colors.ConsoleDateTimeColor),
                label.Pastel(labelColor),
                sender.Pastel(Colors.ConsoleSenderColor),
                message.ToString().Pastel(Colors.ConsoleMessageColor));

            return(Task.CompletedTask);
        }