private Boolean CheckMessageType(LoggerMessageType type) { lock (_lock) { if (_allowedMessageTypesList == null) { String[] allowedMessageTypes = AllowedMessageTypes.ToString().Split(','); _allowedMessageTypesList = new List <String>(); foreach (String curAllowedType in allowedMessageTypes) { _allowedMessageTypesList.Add(curAllowedType.Trim().ToLower()); } } } String[] messageTypes = type.ToString().Split(','); foreach (String curType in messageTypes) { if (!_allowedMessageTypesList.Contains(curType.Trim().ToLower())) { return(false); } } return(true); }
public Boolean Log(LoggerMessageType type, String format, params System.Object[] args) { //This is a special flag which prevents sensitive logging information //for being output when a debugger is not attached. if (type.HasFlag(LoggerMessageType.Sensitive) && !System.Diagnostics.Debugger.IsAttached) { return(false); } else { type = type & ~LoggerMessageType.Sensitive; } //We need all message types to be in the allowed message //types before we can continue String[] allowedMessageTypes = AllowedMessageTypes.ToString().Split(','); List <String> allowedMessageTypesList = new List <String>(); foreach (String curAllowedType in allowedMessageTypes) { allowedMessageTypesList.Add(curAllowedType.Trim().ToLower()); } String[] messageTypes = type.ToString().Split(','); foreach (String curType in messageTypes) { if (!allowedMessageTypesList.Contains(curType.Trim().ToLower())) { return(false); } } LogWritingEventArgs writingArgs = new LogWritingEventArgs(FullPath, type, String.Format(format, args)); Writing?.Invoke(this, writingArgs); System.Diagnostics.Debug.WriteLine(String.Format(format, args)); return(true); }
public void WriteMessage(LoggerMessageType messageType, Exception exception) { mLogWriter.WriteLine("[{0}] [{1:dd.MM.yyyy HH:mm:ss}.{2}] {3}", messageType.ToString().ToUpper(), DateTime.Now, DateTime.Now.Millisecond, exception); mLogWriter.Flush(); }