public void Log(string text, eMsgLevel LVL = eMsgLevel.l4_Message) { try { DateTimeOffset pTime = DateTimeOffset.Now; switch (LVL) { case eMsgLevel.l1_Error: _logger?.LogError($"{{time}}: {text}", pTime); break; case eMsgLevel.l2_Warning: _logger?.LogWarning($"{{time}}: {text}", pTime); break; case eMsgLevel.l7_HostDebugMessage: case eMsgLevel.l6_Debug: _logger?.LogDebug($"{{time}}: {text}", pTime); break; default: _logger?.LogInformation($"{{time}}: {text}", pTime); break; } if (!string.IsNullOrEmpty(startupLogPath)) { File.AppendAllText(startupLogPath, $"{pTime}: {text}\r\n"); } } catch { } }
internal static void ParseUnsubscribe(string pTopics, TheQueuedSender pQSender) { TheBaseAssets.MySYSLOG.WriteToLog(301, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM("CoreComm", $"ParseUnsubscribe for Topics={pTopics} of {pQSender.MyTargetNodeChannel?.ToMLString()}", eMsgLevel.l7_HostDebugMessage)); if (string.IsNullOrEmpty(pTopics) || pQSender == null) { return; } bool WasSubscribed = pQSender.Unsubscribe(pTopics); TheBaseAssets.MySYSLOG.WriteToLog(302, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM("CoreComm", $"ParseUnsubscribe: Removing Topic Topics={pTopics} of {pQSender.MyTargetNodeChannel?.ToMLString()} Was Sub'ed: {WasSubscribed}", eMsgLevel.l7_HostDebugMessage)); #region DebugInfo if (TheBaseAssets.MyServiceHostInfo.DebugLevel > eDEBUG_LEVELS.FULLVERBOSE) { string tContent = "ParseUnsubscribe - Unsubscribed from: " + pTopics; eMsgLevel tLev = eMsgLevel.l4_Message; if (WasSubscribed) { tLev = eMsgLevel.l2_Warning; tContent = "A Subscription was not Found for: " + pTopics; } TheBaseAssets.MySYSLOG.WriteToLog(304, new TSM("CoreComm", tContent, tLev)); } #endregion }
private void Log(eDEBUG_LEVELS logLevel, eMsgLevel messageLevel, string message, string payload = null) { if (IsLevelActive(logLevel)) { TheBaseAssets.MySYSLOG?.WriteToLog(LogId, new TSM(_logName, message, messageLevel, payload)); } }
/// <summary> /// Creates a new TSM with a given Engine, Message Text and Message Level. /// ATTENTION: Only use this Constructor for WriteToLog() entries. /// ATTENTION: This constructor does NOT set the SID by default to avoid performance hit for SID creation /// To change this behavior you have to set "DisableFastTSMs=true" in the App.config /// </summary> /// <param name="tEngine">Engine Name</param> /// <param name="pText">Command Text</param> /// <param name="pLevel">Priority Level of the Message</param> public TSM(string tEngine, string pText, eMsgLevel pLevel) { ENG = tEngine; TXT = pText; LVL = pLevel; SetOrigin(TheBaseAssets.MyServiceHostInfo?.DisableFastTSMs == true ? false : true); }
/// <summary> /// Creates a new TSM with a given Engine and Command Text and Payload /// </summary> /// <param name="tEngine">Engine Name</param> /// <param name="pText">Command Text</param> /// <param name="pLevel">Priority Level of the Message</param> /// <param name="pTimeStamp">Custom Timestamp for the message</param> /// <param name="pPayload">Payload string for the message</param> public TSM(string tEngine, string pText, eMsgLevel pLevel, DateTimeOffset pTimeStamp, string pPayload) { ENG = tEngine; PLS = pPayload; TXT = pText; LVL = pLevel; TIM = pTimeStamp; SetOrigin(); }
/// <summary> /// Creates a new TSM with a given Engine and Command Text and Payload /// </summary> /// <param name="tEngine">Engine Name</param> /// <param name="pText">Command Text</param> /// <param name="pLevel">Priority Level of the Message</param> /// <param name="pPayload">Payload string for the message</param> /// <param name="pQueueIdx">Queue Index for the Message - the lower the faster the message is transported</param> public TSM(string tEngine, string pText, eMsgLevel pLevel, string pPayload, int pQueueIdx) { ENG = tEngine; PLS = pPayload; TXT = pText; LVL = pLevel; QDX = pQueueIdx; SetOrigin(); }
public static void LogEvent(string pEventName, eMsgLevel pEventLevel, string pEventText = null, string pEventTrigger = null, string pEventAction = null) { TheEventLogData tSec = new TheEventLogData { EventCategory = eLoggerCategory.RuleEvent, EventTime = DateTimeOffset.Now, StationName = TheBaseAssets.MyServiceHostInfo?.GetPrimaryStationURL(false), EventName = pEventName, EventString = pEventText, EventTrigger = pEventTrigger, EventLevel = pEventLevel, ActionObject = pEventAction }; TheLoggerFactory.LogEvent(tSec); }
/// <summary> /// Logs an NMI or other User Triggered event /// </summary> /// <param name="pCategory">Event Category</param> /// <param name="pEventName">Name of the event</param> /// <param name="pEventLevel">Seveity of the event</param> /// <param name="pUserID">User that triggered the event</param> /// <param name="pEventText">Long text of the event</param> /// <param name="pActionObject">Optional: What object/thing was impacted by the Event</param> public static void LogEvent(string pCategory, string pEventName, eMsgLevel pEventLevel, Guid pUserID, string pEventText = null, string pActionObject = null) { InitRR(); if (MyLoggerEngine != null) { TheEventLogData tSec = new TheEventLogData { EventTime = DateTimeOffset.Now, StationName = TheBaseAssets.MyServiceHostInfo.GetPrimaryStationURL(false), EventName = pEventName, EventString = pEventText, UserID = pUserID.ToString(), EventLevel = pEventLevel, EventCategory = pCategory }; MyLoggerEngine.LogEvent(tSec); } }
public void WriteToLog(eDEBUG_LEVELS LogLevel, int LogID, string pTopic, string pLogText, eMsgLevel pSeverity = eMsgLevel.l4_Message, bool NoLog = false) { Log($"SYSLOG: ID:{LogID} Topic:{pTopic} {pLogText}", pSeverity); }
/// <summary> /// Writes to the SystemLog /// </summary> /// <param name="LogID"></param> /// <param name="LogLevel"></param> /// <param name="pTopic"></param> /// <param name="pSeverity"></param> /// <param name="pLogText"></param> /// <param name="NoLog"></param> public void WriteToLog(eDEBUG_LEVELS LogLevel, int LogID, string pTopic, string pLogText, eMsgLevel pSeverity = eMsgLevel.l4_Message, bool NoLog = false) { if (TSM.L(LogLevel)) { return; } WriteToLog(LogID, new TSM(pTopic, pLogText, pSeverity), NoLog); }