Exemplo n.º 1
0
        private bool ShouldAdd(LogArguments logArguments, Func <LogArguments, IConfiguration, TLog> toLog)
        {
            if (!logArguments.IsLevelAllowed(configuration.Level))
            {
                return(false);
            }

            var key = $"{DateTime.Now.ToString(AsKey)}-{Guid.NewGuid()}";
            var log = toLog(logArguments, configuration);

            lock (padlock)
                logs.Add(key, log);

            return(true);
        }
Exemplo n.º 2
0
 private void WriteToFile(LogArguments logArguments) => logBuffer
 .Check(logArguments.IsLevelAllowed(configuration.Level))
 ?.Add(logArguments.ToStringLogUsing(configuration))
 .Validate(configuration.BufferSize)
 ?.Write(FileBulkWriter.ToFileAsync, kv => $"{kv.Value}{Environment.NewLine}");
 private void WriteToConsole(LogArguments logArguments) => logBuffer
 .Check(logArguments.IsLevelAllowed(configuration.Level))
 ?.Add(logArguments.ToStringLogUsing(configuration))
 .Validate(configuration.BufferSize)
 ?.Write(ConsoleBulkWriter.ToConsole, kv => kv.Value);
 private void WriteToDatabase(LogArguments logArguments) => logBuffer
 .Check(logArguments.IsLevelAllowed(configuration.Level))
 ?.Add(logArguments.ToDatabaseLogUsing(configuration))
 .Validate(configuration.BufferSize)
 ?.Write(DatabaseBulkWriter.ToDatabaseAsync, kv => kv.Value);