コード例 #1
0
ファイル: Plugin.cs プロジェクト: nike4613/bsaml
        void ILogEventSink.Emit(LogEvent logEvent)
        {
            var level = logEvent.Level switch
            {
                LogEventLevel.Verbose => IPALogger.Level.Debug,
                LogEventLevel.Debug => IPALogger.Level.Debug,
                LogEventLevel.Information => IPALogger.Level.Info,
                LogEventLevel.Warning => IPALogger.Level.Warning,
                LogEventLevel.Error => IPALogger.Level.Error,
                LogEventLevel.Fatal => IPALogger.Level.Critical,
                _ => Do(() => ipaLogger.Warn($"Invalid Serilog level {logEvent.Level}"), IPALogger.Level.Info),
            };
            string prefix = "";

            if (logEvent.Properties.TryGetValue("ForPlugin", out var value) &&
                value is ScalarValue scalar &&
                scalar.Value is PluginMetadata meta)
            {
                prefix += $"[{meta.Name}] ";
            }

            if (logEvent.Properties.TryGetValue("SourceContext", out value) &&
                value is ScalarValue scalar2 &&
                scalar2.Value is string scontext)
            {
                prefix += $"{{{scontext}}}: ";
            }

            ipaLogger.Log(level, prefix + logEvent.RenderMessage());
            if (logEvent.Exception != null)
            {
                ipaLogger.Log(level, logEvent.Exception);
            }
        }
コード例 #2
0
        private void DiscordLogCallback(LogLevel level, string message)
        {
            switch (level)
            {
            case LogLevel.Debug:
            {
                log.Log(IPA.Logging.Logger.Level.Debug, $"[DISCORD] {message}");
            }
            break;

            case LogLevel.Info:
            {
                log.Log(IPA.Logging.Logger.Level.Info, $"[DISCORD] {message}");
            }
            break;

            case LogLevel.Warn:
            {
                log.Log(IPA.Logging.Logger.Level.Warning, $"[DISCORD] {message}");
            }
            break;

            case LogLevel.Error:
            {
                log.Log(IPA.Logging.Logger.Level.Error, $"[DISCORD] {message}");
            }
            break;
            }
        }
コード例 #3
0
        public static void Log(string m, LogInfo l, string suggestedAction)
        {
            if (BSIPALogger == null)
            {
                return;
            }
            IPALogger.Level level = IPALogger.Level.Debug;
            switch (l)
            {
            case LogInfo.Info: level = IPALogger.Level.Debug; break;

            case LogInfo.Notice: level = IPALogger.Level.Notice; break;

            case LogInfo.Warning: level = IPALogger.Level.Warning; break;

            case LogInfo.Error: level = IPALogger.Level.Error; break;

            case LogInfo.Fatal: level = IPALogger.Level.Critical; break;
            }
            BSIPALogger.Log(level, m);
            if (suggestedAction != null)
            {
                BSIPALogger.Log(level, $"Suggested Action: {suggestedAction}");
            }
        }
コード例 #4
0
 public override void Log(string message, LogLevel logLevel)
 {
     if (LoggingLevel > logLevel)
     {
         return;
     }
     if (!string.IsNullOrEmpty(SourceName))
     {
         IPALogger.Log(logLevel.ToIPALogLevel(), message);
     }
     else
     {
         IPALogger.Log(logLevel.ToIPALogLevel(), message);
     }
 }
コード例 #5
0
        public static void Log(string m, LogLevel l, string suggestedAction)
        {
            IPA.Logging.Logger.Level level = IPA.Logging.Logger.Level.Debug;
            switch (l)
            {
            case LogLevel.Debug: level = IPA.Logging.Logger.Level.Debug; break;

            case LogLevel.Notice: level = IPA.Logging.Logger.Level.Notice; break;

            case LogLevel.Warning: level = IPA.Logging.Logger.Level.Warning; break;

            case LogLevel.Error: level = IPA.Logging.Logger.Level.Error; break;

            case LogLevel.Critical: level = IPA.Logging.Logger.Level.Critical; break;
            }
            logger.Log(level, m);
            if (suggestedAction != null)
            {
                logger.Log(level, $"Suggested Action: {suggestedAction}");
            }
        }
コード例 #6
0
ファイル: Logger.cs プロジェクト: denpadokei/CustomMenuMusic
        public static void Log(string m, LogLevel l, string suggestedAction = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int?line = null, [CallerMemberName] string member = null)
        {
            var level = IPA.Logging.Logger.Level.Debug;

            switch (l)
            {
            case LogLevel.Debug: level = IPA.Logging.Logger.Level.Debug; break;

            case LogLevel.Notice: level = IPA.Logging.Logger.Level.Notice; break;

            case LogLevel.Warning: level = IPA.Logging.Logger.Level.Warning; break;

            case LogLevel.Error: level = IPA.Logging.Logger.Level.Error; break;

            case LogLevel.Critical: level = IPA.Logging.Logger.Level.Critical; break;
            }
            logger.Log(level, $"{Path.GetFileName(filePath)}({line})[{member}] : {m}");
            if (!string.IsNullOrEmpty(suggestedAction))
            {
                logger.Log(level, $"{Path.GetFileName(filePath)}({line})[{member}] Suggested Action: {suggestedAction}");
            }
        }
コード例 #7
0
ファイル: Logging.cs プロジェクト: zolcsieles/SongCore
 internal static void Log(string message, IPALogger.Level level)
 {
     logger.Log(level, $"{message}");
 }
コード例 #8
0
 public override void Flush()
 {
     logger.Log(level, builder.ToString());
     builder.Clear();
 }
コード例 #9
0
 internal static void Log(string message = "<3", Level level = Level.Info)
 {
     logger.Log(level, message);
 }