Example #1
0
        internal static async Task FlushAllAsync(LogWriteContext context)
        {
            var tasks = new List<Task>();
            foreach (var manager in Owners.Values)
                tasks.Add(manager.LazyFlushAsync(context));

            // wait...
            await Task.WhenAll(tasks);
        }
Example #2
0
        public static async Task FlushAllAsync(LogWriteContext context)
        {
            var tasks = new List <Task>();

            foreach (var manager in Owners.Values)
            {
                tasks.Add(manager.LazyFlushAsync(context));
            }

            // wait...
            await Task.WhenAll(tasks);
        }
Example #3
0
        sealed protected override async Task<LogWriteOperation> WriteAsyncCore(LogWriteContext context, LogEventInfo entry)
        {
            using (await _lock.LockAsync())
            {
                await EnsureInitialized();
                await CheckCleanupAsync();

                var filename = FileNamingParameters.GetFilename(context, entry);
                var contents = Layout.GetFormattedString(context, entry);

                return await DoWriteAsync(filename, contents, entry);
            }
        }
Example #4
0
        private async Task LazyFlushAsync(LogWriteContext context)
        {
            List<ILazyFlushable> toNotify = null;
            lock (_lock)
                toNotify = new List<ILazyFlushable>(this.Clients);

            // walk...
            if (toNotify.Any())
            {
                var tasks = toNotify.Select(client => client.LazyFlushAsync(context)).ToList();

                // wait...
                await Task.WhenAll(tasks);
            }
        }
Example #5
0
        async Task LazyFlushAsync(LogWriteContext context)
        {
            List <ILazyFlushable> toNotify = null;

            lock (_lock)
                toNotify = new List <ILazyFlushable>(this.Clients);

            // walk...
            if (toNotify.Any())
            {
                var tasks = toNotify.Select(client => client.LazyFlushAsync(context)).ToList();

                // wait...
                await Task.WhenAll(tasks);
            }
        }
Example #6
0
        public override string GetFormattedString(LogWriteContext context, LogEventInfo info)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("{0:0000000}", info.SequenceID);
            builder.Append("|");
            builder.Append(info.TimeStamp.ToString("s"));
            builder.Append("|");
            builder.AppendFormat("{0,-5}", info.Level.ToString().ToUpper());
            builder.Append("|");
            builder.AppendFormat("{0:000}", Environment.CurrentManagedThreadId);
            builder.Append("|");
            builder.AppendFormat(" [{0}]", info.Logger);
            builder.Append(" ");
            builder.Append(info.Message);
            if (info.Exception != null)
            {
                builder.AppendLine();
                builder.AppendLine("EXCEPTION:");
                builder.Append(string.Join(Environment.NewLine + Environment.NewLine, ExceptionUtils.UnwrapExceptions(info.Exception)));
            }

            return builder.ToString();
        }
Example #7
0
 protected override void Write(LogWriteContext context, LogEventInfo entry)
 {
     Action(entry);
 } 
Example #8
0
 protected override void Write(LogWriteContext context, LogEventInfo entry)
 {
     Console.WriteLine(Layout.GetFormattedString(context, entry));
 }