Пример #1
0
 private void WriteToLog(Func <string> logMessage)
 {
     if (_logger != null)
     {
         _logger.Log(logMessage());
     }
 }
Пример #2
0
        void log(LogLevel level, string message, params object[] args)
        {
            if (adapter != null)
            {
                if ((Log.level & level) == level)
                {
                    lock (syncRoot)
                    {
                        adapter.Log(
                            new LogEvent
                        {
                            Level   = level,
                            Log     = this,
                            Message = String.Format(message, args),
                            Time    = timer.Elapsed
                        }
                            );
                    }
                }
            }
            else
            {
                if (NoAdapterSet != null)
                {
                    lock (syncRoot)
                    {
                        if (adapter != null)
                        {
                            NoAdapterSet.Invoke();
                        }
                    }
                }

                if (adapter != null)
                {
                    log(level, message, args);
                    return;
                }

                throw new RuntimeException("No logging adapter set, you need to call Log.SetAdapter");
            }
        }