Пример #1
0
        public static void Error(string message, LoggerBllType bllType, object args = null, [CallerFilePath] string file = null,
                                 [CallerLineNumber] int line      = 0,
                                 [CallerMemberName] string member = null)
        {
            var stackInfo = GetFileInfo(file, line, member);

            Write(LogLevel.Error, stackInfo, message, bllType, null, args);
        }
Пример #2
0
        public static void Warn(Exception exception, LoggerBllType bllType, object args = null, [CallerFilePath] string file = null,
                                [CallerLineNumber] int line      = 0,
                                [CallerMemberName] string member = null)
        {
            var stackInfo = GetFileInfo(file, line, member);

            Write(LogLevel.Error, stackInfo, exception.StackTrace, bllType, exception, args);
        }
Пример #3
0
        public static void Info(object message, LoggerBllType bllType, object args = null, [CallerFilePath] string file = null,
                                [CallerLineNumber] int line      = 0,
                                [CallerMemberName] string member = null)
        {
            var stackInfo = $"{GetFileInfo(file, line, member)}";

            Write(LogLevel.Info, stackInfo, message.ToString(), bllType, null, args);
        }
Пример #4
0
        public static void Fatal(string message, Exception exception, LoggerBllType bllType, object args = null, [CallerFilePath] string file = null,
                                 [CallerLineNumber] int line      = 0,
                                 [CallerMemberName] string member = null)
        {
            var stackInfo = GetFileInfo(file, line, member);

            Write(LogLevel.Fatal, stackInfo, message, bllType, exception, args);
        }
Пример #5
0
        private static async void Write(LogLevel FLogLevel, string stackInfo, string message, LoggerBllType bllType, Exception exception, object args)
        {
            string argsStr = null;

            if (args != null)
            {
                argsStr = args.ToJson();
            }

            await MyLogger.WriteMessage(FLogLevel, stackInfo, message, argsStr, bllType, exception);
        }
Пример #6
0
        public async Task WriteMessage(LogLevel FLogLevel, string stackInfo, string message, string args, LoggerBllType bllType, Exception exception)
        {
            var entity = new TLogger
            {
                FBllType   = bllType,
                FLogLevel  = FLogLevel,
                FStackInfo = stackInfo,
                FMessage   = message,
                FArgs      = args,
            };

            if (exception != null)
            {
                entity.FExceptionName    = exception.GetType().Name;
                entity.FExceptionMessage = exception.Message;
                entity.FExceptionInfo    = exception.ToString();
            }

            entity.SetCreator("Sys");
            ConsoleLogger.WriteMessage(entity);

#if SERVER
            await LoggerWriter.FileWriterFatory.WriteMessage(entity);

            await LoggerWriter.MongoWriterFatory.WriteMessage(entity);
#endif
            await Task.CompletedTask;
        }