Пример #1
0
        private LogMessage GetLogMessage(string message, string logKey, LogLevel logLevel, string logName, int logSource, LoggerTrace logTrace)
        {
            Guid       logBodyKey = Guid.NewGuid();
            LogMessage logmessage = new LogMessage
            {
                LogHead = new LogHead
                {
                    Id          = Guid.NewGuid(),
                    LogBodyKey  = logBodyKey,
                    LogDateTime = DateTime.Now,
                    LogKey      = logKey,
                    LogLevel    = logLevel,
                    //TODO:后续完善
                    LogName         = logName,
                    LogSource       = logSource,
                    ApplicationName = "",
                    ServerIp        = "",
                    ModulesName     = ""
                },
                LogBody = new LogBody
                {
                    Id             = logBodyKey,
                    LogBodyContent = message
                }
            };

            if (logTrace != null)
            {
                logmessage.LogHead.TraceId  = logTrace.TraceId;
                logmessage.LogHead.LocalId  = logTrace.LocalId;
                logmessage.LogHead.ParentId = logTrace.ParentId;
            }
            return(logmessage);
        }
Пример #2
0
 public void SetLogTrace(LoggerTrace logTrace)
 {
     _LoggerTrace = logTrace;
 }
Пример #3
0
        public void Warn(string message, string logKey, int logSource = 0, string logName = null, LoggerTrace logTrace = null)
        {
            LogMessage logMessage = GetLogMessage(message, logKey, LogLevel.WARN, logName, logSource, logTrace);

            SaveLogMessage(logMessage);
        }