Beispiel #1
0
 public FileLog(long key, Func <LogType, LogLevel, bool> filter, LogFileWriter writer)
 {
     _key    = key;
     _filter = filter;
     _writer = writer;
     _start  = DateTime.UtcNow;
 }
Beispiel #2
0
        public void Dispose()
        {
            _configRegistration?.Dispose();
            _configRegistration = null;

            _logFileWriter?.Dispose();
            _logFileWriter = null;
        }
Beispiel #3
0
        public LogFactory(
            IConfigurationStore configurationStore)
        {
            _configRegistration = configurationStore.Register(
                "/gravity/log",
                c =>
            {
                _filter = ConstructFilter(c.LogTypes, c.MaximumLogLevel);

                if ((int)c.MaximumLogLevel < 1)
                {
                    c.Enabled = false;
                }

                if (c.Method == LogMethod.File)
                {
                    if (string.IsNullOrWhiteSpace(c.Directory))
                    {
                        c.Enabled = false;
                    }
                    else
                    {
                        var oldWriter  = _logFileWriter;
                        _logFileWriter = new LogFileWriter(
                            new DirectoryInfo(c.Directory),
                            "log_",
                            c.MaximumLogFileAge,
                            c.MaximumLogFileSize,
                            false);
                        oldWriter?.Dispose();
                    }
                }

                _configuration = c;
            },
                new Configuration());
        }