public ConsoleLog(Log.Level level) { CurrentLevel = level; }
private bool IsContainsLevel(Log.Level l) { //return ((_filterLevel & l) == l); old way return(_filterLevel.HasFlag(l)); //new way from .NET 4 }
public void OnMessage(Log.Level level, string message, string formattedLine) { Debug.Write(formattedLine); }
/// <summary>Log a message</summary> /// <param name="timestamp">Log timestamp</param> /// <param name="level">Log level</param> /// <param name="message">Log message</param> /// <param name="thread">Source thread</param> /// <param name="stackTrace">Stack trace</param> public void LogMessage(DateTime timestamp, Log.Level level, string message, string thread, string stackTrace) { this.messages.Add(new Message { Timestamp = timestamp, Level = level, Text = message, Thread = thread, Stacktrace = stackTrace }); }
void loglevel(Log.Level level) { Log.level = level; }
public Good4(Log.Level level) { m_level = level; Console.WriteLine(m_level); }
/// <summary>Gets all messages logged with a level</summary> /// <param name="level">Level of the messages to get</param> /// <returns>The messages</returns> private IEnumerable <Message> GetMessagesForLevel(Log.Level level) { return(this.messages.Where(msg => msg.Level == level)); }
public void log(Log.Level l, object o) => logInner(l, line(l.ToString(), o));
protected abstract void logInner(Log.Level l, string s);
public void log(Log.Level l, object o) => defer(() => backing.log(l, o));
public bool willLog(Log.Level l) => this.level >= l;
protected override void logInner(Log.Level l, string s, Option <Object> context) { }
protected abstract void logInner(Log.Level l, string s, Option <Object> context);
public void log(Log.Level l, object o, Object context = null) => logInner(l, line(l.ToString(), o), context.opt());
public bool Update() { var updated = false; if (this.SettingVersion == 1) { this.LogLevel = Log.Level.None; this.SettingVersion = 2; updated = true; } if (!string.IsNullOrEmpty(this.ProxyPassword) && string.IsNullOrEmpty(this.EncryptedProxyPassword)) { var rsa = new CipherRsa(this.KeyContainerName); this.EncryptedProxyPassword = rsa.Encrypt(this.ProxyPassword); this.ProxyPassword = string.Empty; updated = true; } return updated; }
protected override void logInner(Log.Level l, string s) { }
public bool willLog(Log.Level l) => level >= l;
public void log(Log.Level l, object o) => backing.log(l, wrap(o));
public void PluginLog(Log.Level logLevel, string Message) { Log.Write(logLevel, PluginInfo.Name + ": " + Message); }
protected ErrorCode LogDuration(string description, Log.Level level = Log.Level.Info) { Log.Timer(level, description, timer); timer.Restart(); return(ErrorCode.Success); }
/// <summary>Initializes a new instance of the TestLogger class.</summary> /// <param name="levels">Levels to log</param> public TestLogger(Log.Level levels) { this.messages = new List <Message>(); this.Levels = levels; }
bool IsEnabled(Log.Level logLevel) { return((_logLevel & logLevel) == logLevel); }
public static ITiming ifLogLevel(this ITiming backing, Log.Level level, ILog log = null) => new TimingConditional(backing, (log ?? Log.defaultLogger).willLog(level));
private void LogCallback(Log.Level level, string message) { console.Write(level, message); }
private void LogCallback(Log.Level level, string message) { MessageBox.Show(message, "Log Message"); }
public void LogCallback(Log.Level level, String message) { string dt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Console.WriteLine(dt + ' ' + level.ToString() + ' ' + message); }
static void LogCallback(Log.Level level, string message) => Console.WriteLine(DateTime.Now.ToString() + ' ' + level + ' ' + message);
public Config() { string line; string[] data; string[] addressList; string[] ipport; char[] optionSplitChars = new char[] { '=' }; char[] addrSplitChars = new char[] { ':' }; int lineNumber = 0, port; string addr; IPAddress ipaddr; IPEndPoint endpoint; using (StreamReader r = new StreamReader(new FileStream(ConfigFilePath, FileMode.Open), Encoding.UTF8)) { while (!r.EndOfStream) { lineNumber++; line = r.ReadLine().Trim(); if (line.Length == 0 || line[0] == '#') { continue; } data = line.Split(optionSplitChars, 2); if (data.Length < 2) { throw new Exception(String.Format("Misformatted configuration option on line {0}", lineNumber)); } data[0] = data[0].Trim(); if (data[0].Length == 0) { throw new Exception(String.Format("Misformatted configuration option on line {0}", lineNumber)); } data[1] = data[1].Trim(); if (data[1].Length == 0) { continue; // empty option is considered to have a default value } switch (data[0].ToLower()) { case "log": LogPath = data[1].Equals("") ? null : data[1]; break; case "log_level": switch (data[1].ToLower()) { case "debug": LogLevel = Log.Level.Debug; break; case "info": LogLevel = Log.Level.Info; break; case "warning": LogLevel = Log.Level.Warning; break; case "error": LogLevel = Log.Level.Error; break; } break; case "bind_addr": addressList = data[1].Split(',', ';', ' ', '\t'); foreach (string xaddr in addressList) { addr = xaddr.Trim(); if (addr.Length == 0) { continue; } ipport = addr.Split(addrSplitChars, 2); if (ipport.Length < 2 || !int.TryParse(ipport[1], out port)) { port = 11211; // default memcached port is 11211 } if (ipport[0].Equals("*")) { BindAddr.Clear(); BindAddr.Add(new IPEndPoint(IPAddress.Any, port)); break; } else if (ipport[0].Equals("localhost")) { ipaddr = IPAddress.Loopback; } else if (!IPAddress.TryParse(ipport[0], out ipaddr)) { throw new Exception(String.Format("Invalid IP address on line {0}", lineNumber)); } endpoint = new IPEndPoint(ipaddr, port); if (!BindAddr.Contains(endpoint)) { BindAddr.Add(endpoint); } } break; case "allowed_addr": addressList = data[1].Split(',', ';', ' ', '\t'); foreach (string xaddr in addressList) { addr = xaddr.Trim(); if (addr.Length == 0) { continue; } if (addr.Equals("*")) { AllowedAddr.Clear(); AllowedAddr.Add(IPAddress.Any, true); break; } else if (addr.Equals("localhost")) { ipaddr = IPAddress.Loopback; } else if (!IPAddress.TryParse(addr, out ipaddr)) { throw new Exception(String.Format("Invalid IP address on line {0}", lineNumber)); } if (!AllowedAddr.ContainsKey(ipaddr)) { AllowedAddr.Add(ipaddr, true); } } break; case "next_server_addr": ipport = data[1].Split(addrSplitChars, 2); if (ipport.Length < 2 || !int.TryParse(ipport[1], out port)) { port = 11211; // default memcached port is 11211 } if (ipport[0].Equals("localhost")) { NextServerAddr = new IPEndPoint(IPAddress.Loopback, port); } else if (IPAddress.TryParse(ipport[0], out ipaddr)) { NextServerAddr = new IPEndPoint(ipaddr, port); } else { throw new Exception(String.Format("Invalid IP address on line {0}", lineNumber)); } break; case "max_storage": if (!long.TryParse(data[1], out MaxStorage)) { char sizeMod = data[1][data[1].Length - 1]; data[1] = data[1].Substring(0, data[1].Length - 1); if (!long.TryParse(data[1], out MaxStorage)) { throw new Exception(String.Format("Invalid size value on line {0}", lineNumber)); } if (sizeMod == 'k' || sizeMod == 'K') { MaxStorage *= 1024; } else if (sizeMod == 'm' || sizeMod == 'M') { MaxStorage *= 1024 * 1024; } else if (sizeMod == 'g' || sizeMod == 'G') { MaxStorage *= 1024 * 1024 * 1024; } else { throw new Exception(String.Format("Invalid size modifier on line {0}. Only 'K', 'M' and 'G' modifiers supported.", lineNumber)); } } break; case "server_id": if (!uint.TryParse(data[1], out ServerId)) { throw new Exception(String.Format("'server_id' configuration option must be a 32 bit integer on line {0}", lineNumber)); } break; case "tag_character": if (data[1].Length > 1) { Log.WriteLine(Log.Level.Warning, "'tag_character' configuration option has a value of multiple characters on line {0}. Only First character will be used.", lineNumber); } TagCharacter = data[1][0]; break; } } } // fill in default values if (BindAddr.Count == 0) { BindAddr.Add(new IPEndPoint(IPAddress.Loopback, 11211)); } if (AllowedAddr.Count == 0) { foreach (IPEndPoint ep in BindAddr) { if (ep.Address == IPAddress.Any) { // TODO: need to detect which ip addresses the current machine has and add them to that list AllowedAddr.Add(IPAddress.Loopback, true); } else { AllowedAddr.Add(ep.Address, true); } } } if (LogPath == null || LogPath.Equals("")) { LogPath = "syslog"; } }
public int FilterLogs(Log.Category categories, Log.Level level, string keyword) { return(FilterLogs(categories, level, keyword, -1)); }
public bool willLog(Log.Level l) => backing.willLog(l);
public SettingInfo() { SettingVersion = 2; this.LogLevel = Log.Level.None; }
public void log(Log.Level l, LogEntry entry) => backing.log(l, entry.withMessage(wrap(entry.message)));
/// <summary> /// すべての設定値をクリアする。 /// </summary> public void Clear() { ProxyServer = string.Empty; ProxyUser = string.Empty; ProxyPassword = string.Empty; BypassList = new string[] { }; this.LogLevel = Log.Level.None; }
public void log(Log.Level l, object o, Object context = null) => defer(() => backing.log(l, o, context));