Пример #1
0
        public void Log(Func <string> messageProc, LogMask mask, Servarity sevarity = Servarity.Diagnostic)
        {
            bool shouldWriteToLog   = false;
            bool shouldWriteToDebug = false;

            if (sevarity == Servarity.Normal)
            {
                shouldWriteToLog   = true;
                shouldWriteToDebug = true;
            }
            else if (mask == DiagnosticMask || DiagnosticMask == LogMask.All)
            {
                shouldWriteToLog = true;
            }

            if (shouldWriteToDebug || shouldWriteToLog)
            {
                string message = messageProc();

                if (shouldWriteToDebug)
                {
                    System.Diagnostics.Debug.WriteLine($"[{mask}] {message}");
                }
                if (shouldWriteToLog)
                {
                    LogStream.WriteLine($"[{mask}] {message}");
                }
            }
            if (sevarity == Servarity.Normal)
            {
                LogStream.Flush();
            }
        }
Пример #2
0
 public void Log(string message, LogMask mask, Servarity sevarity = Servarity.Diagnostic)
 {
     Log(() => message, mask, sevarity);
 }