コード例 #1
0
 public static AnalogyLogMessage LogMessageFromLogInfo(LogInfoWithJsonAttributes lf)
 {
     if (string.IsNullOrEmpty(lf.AdditionalInfo))
     {
         AnalogyLogMessage message = new AnalogyLogMessage();
         message.Id = Guid.NewGuid();
         //todo
         //message.Class = lf.Severity == Enum.GetName(typeof(Severity), Severity.Hazard)
         //    ? AnalogyLogClass.Hazard
         //    : AnalogyLogClass.General;
         // message.auditType = "This can't be an audit message";
         //message.atnaMessage = "This can't be an audit message";
         message.MethodName = lf.Exception == null ? "" : lf.StackTrace;
         //message.FileName = ;
         //message.LineNumber = ;
         message.User = "";
         //message.Parameters = "BIG msg will not come here";
         message.Module      = lf.ProcessName;           // event id can be shown as module
         message.Source      = lf.HumanReadableModuleId; // module is nt source in PF2.0
         message.Level       = GetAnalogyLogLevel(lf.Severity);
         message.Text        = lf.Description + lf.Exception;
         message.ProcessId   = Convert.ToInt32(lf.ProcessId);
         message.Date        = lf.DateTime;
         message.MachineName = lf.MachineName ?? string.Empty;
         message.Category    = "Platform2.0";
         return(message);
     }
     else
     {
         return(ConditionalLogMessage(lf));
     }
 }
コード例 #2
0
        private static AnalogyLogMessage ConditionalLogMessage(LogInfoWithJsonAttributes lf)
        {
            AnalogyLogMessage logMessage = new AnalogyLogMessage();

            logMessage.Module      = !ContainsGuid(lf.AdditionalInfo) ? lf.ProcessName : lf.HumanReadableModuleId;
            logMessage.Source      = lf.HumanReadableEventId;
            logMessage.Level       = GetAnalogyLogLevel(lf.Severity);
            logMessage.Text        = lf.Description;
            logMessage.ProcessId   = Convert.ToInt32(lf.ProcessId);
            logMessage.Date        = lf.DateTime;
            logMessage.MachineName = lf.MachineName ?? string.Empty;
            SetAdditionalLogMessage(logMessage, lf.AdditionalInfo + lf.Exception);
            logMessage.MethodName = string.IsNullOrEmpty(lf.Exception) ? "" : lf.Exception;
            return(logMessage);
        }