示例#1
0
        public void Log(WurmApi.LogLevel level, string message, object source, Exception exception)
        {
            var nlogLevel = Convert(level);
            if (logger.IsEnabled(nlogLevel))
            {
                string prefix = string.Empty;
                if (source != null)
                {
                    var stringSource = source as string;
                    if (!string.IsNullOrEmpty(stringSource))
                    {
                        prefix += "." + stringSource;
                    }
                    else
                    {
                        prefix += source.GetType().Name;
                    }
                }

                message = "WurmApi > " + prefix + ": " + message;

                logger.Log(nlogLevel, exception, message);
                logMessageProcessor.Handle(nlogLevel, message, exception);
            }
        }
示例#2
0
 LogLevel Convert(WurmApi.LogLevel wurmApiLevel)
 {
     switch (wurmApiLevel)
     {
         case WurmApi.LogLevel.Diag:
             return LogLevel.Trace;
         case WurmApi.LogLevel.Error:
             return LogLevel.Error;
         case WurmApi.LogLevel.Fatal:
             return LogLevel.Fatal;
         case WurmApi.LogLevel.Info:
             return LogLevel.Info;
         case WurmApi.LogLevel.Warn:
             return LogLevel.Warn;
         default:
             return LogLevel.Info;
     }
 }