示例#1
0
 public ConsoleLog(Log.Level level)
 {
     CurrentLevel = level;
 }
示例#2
0
 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);
 }
示例#4
0
 /// <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
     });
 }
示例#5
0
 void loglevel(Log.Level level)
 {
     Log.level = level;
 }
 public Good4(Log.Level level)
 {
     m_level = level;
     Console.WriteLine(m_level);
 }
示例#7
0
 /// <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));
 }
示例#8
0
文件: Log.cs 项目: Hengle/Tetris-1
 public void log(Log.Level l, object o) => logInner(l, line(l.ToString(), o));
示例#9
0
文件: Log.cs 项目: Hengle/Tetris-1
 protected abstract void logInner(Log.Level l, string s);
示例#10
0
文件: Log.cs 项目: Hengle/Tetris-1
 public void log(Log.Level l, object o) => defer(() => backing.log(l, o));
示例#11
0
文件: Log.cs 项目: Hengle/Tetris-1
 public bool willLog(Log.Level l) => this.level >= l;
示例#12
0
 protected override void logInner(Log.Level l, string s, Option <Object> context)
 {
 }
示例#13
0
 protected abstract void logInner(Log.Level l, string s, Option <Object> context);
示例#14
0
 public void log(Log.Level l, object o, Object context = null) =>
 logInner(l, line(l.ToString(), o), context.opt());
示例#15
0
        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;
        }
示例#16
0
文件: Log.cs 项目: Hengle/Tetris-1
 protected override void logInner(Log.Level l, string s)
 {
 }
示例#17
0
 public bool willLog(Log.Level l) => level >= l;
示例#18
0
 public void log(Log.Level l, object o) => backing.log(l, wrap(o));
示例#19
0
 public void PluginLog(Log.Level logLevel, string Message)
 {
     Log.Write(logLevel, PluginInfo.Name + ": " + Message);
 }
示例#20
0
 protected ErrorCode LogDuration(string description, Log.Level level = Log.Level.Info)
 {
     Log.Timer(level, description, timer);
     timer.Restart();
     return(ErrorCode.Success);
 }
示例#21
0
 /// <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;
 }
示例#22
0
 bool IsEnabled(Log.Level logLevel)
 {
     return((_logLevel & logLevel) == logLevel);
 }
示例#23
0
文件: Timing.cs 项目: Marwan0/tlplib
 public static ITiming ifLogLevel(this ITiming backing, Log.Level level, ILog log = null) =>
 new TimingConditional(backing, (log ?? Log.defaultLogger).willLog(level));
示例#24
0
 private void LogCallback(Log.Level level, string message)
 {
     console.Write(level, message);
 }
示例#25
0
 private void LogCallback(Log.Level level, string message)
 {
     MessageBox.Show(message, "Log Message");
 }
示例#26
0
            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);
            }
示例#27
0
 static void LogCallback(Log.Level level, string message) =>
 Console.WriteLine(DateTime.Now.ToString() + ' ' + level + ' ' + message);
示例#28
0
        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";
            }
        }
示例#29
0
文件: Log.cs 项目: bp-tags/NIKit
 public int FilterLogs(Log.Category categories, Log.Level level, string keyword)
 {
     return(FilterLogs(categories, level, keyword, -1));
 }
示例#30
0
 public bool willLog(Log.Level l) => backing.willLog(l);
示例#31
0
 public SettingInfo()
 {
     SettingVersion = 2;
     this.LogLevel = Log.Level.None;
 }
示例#32
0
 public void log(Log.Level l, LogEntry entry) =>
 backing.log(l, entry.withMessage(wrap(entry.message)));
示例#33
0
 /// <summary>
 /// すべての設定値をクリアする。
 /// </summary>
 public void Clear()
 {
     ProxyServer = string.Empty;
     ProxyUser = string.Empty;
     ProxyPassword = string.Empty;
     BypassList = new string[] { };
     this.LogLevel = Log.Level.None;
 }
示例#34
0
 public void log(Log.Level l, object o, Object context = null) =>
 defer(() => backing.log(l, o, context));