Esempio n. 1
0
        public static void Warning(string source,
                                   string message,
                                   ICommandContext context,
                                   Exception exception = null)
        {
            var msg = Message(source, message, LogSeverity.Warning);

            if (SkuldAppContext.GetLogSeverity() >= LogSeverity.Warning)
            {
                Console.Out.WriteLine(msg);
            }

            if (exception is not null)
            {
                var m = msg + "EXTRA INFORMATION:\n" + exception.ToString();

                if (SkuldAppContext.GetLogSeverity() >= LogSeverity.Warning || exception is not null)
                {
                    if (sentryClient is not null)
                    {
                        SentryEvent @event;
                        if (context is not null)
                        {
                            @event = context.ToSentryEvent(exception);
                        }
                        else
                        {
                            @event = exception.ToSentryEvent();
                        }

                        @event.Level = SentryLevel.Warning;
                        @event.SetTag("Source", source);

                        if (@event is not null)
                        {
                            sentryClient.CaptureEvent(@event);
                        }
                    }
                }

                if (LogFile is not null)
                {
                    LogFile.WriteLine(m);
                }
            }
            else if (LogFile is not null)
            {
                LogFile.WriteLine(msg);
            }

            Console.ForegroundColor = ConsoleColor.White;

            if (LogFile is not null)
            {
                LogFile.Flush();
            }
        }
Esempio n. 2
0
        public static void Info(string source,
                                string message)
        {
            var msg = Message(source, message, LogSeverity.Info);

            if (SkuldAppContext.GetLogSeverity() >= LogSeverity.Info)
            {
                Console.Out.WriteLine(msg);
            }

            if (LogFile is not null)
            {
                LogFile.WriteLine(msg);
            }

            Console.ForegroundColor = ConsoleColor.White;

            if (LogFile is not null)
            {
                LogFile.Flush();
            }
        }