Beispiel #1
0
    private static void Line(object content, string title, ConsoleColor textColor)
    {
        if (_options.ExecuteAsync)
        {
            _queue.Enqueue(Finalize);
        }
        else
        {
            Finalize();
        }

        void Finalize()
        {
            var time = _options.IncludeTime ? $"[{DateTime.Now.ToShortTimeString()}]" : string.Empty;
            var log  = $"{time}{ title }{ content }";

            Console.ForegroundColor = textColor;
            Console.WriteLine(log);

            if (textColor != _options.DefaultColor)
            {
                Console.ForegroundColor = _options.DefaultColor;
            }

            if (_options.SaveLog)
            {
                _log.AppendLine(log);

                var ts = DateTime.Now - _lastSaveTime;
                if (ts.TotalMilliseconds >= _options.SaveLogTimerMs)
                {
                    SaveNow();
                }
            }
        }
    }
Beispiel #2
0
 internal static void PoolAsyncOperation(BasicAction action)
 {
     _queue.Enqueue(action);
 }