Exemplo n.º 1
0
        /// <summary>
        /// Logs the specified log entry.
        /// </summary>
        /// <param name="logEntry">The log entry to log.</param>
        /// <param name="callerMemberName">The method or property name of the caller.</param>
        /// <param name="callerFilePath">The path of the source file that contains the caller.</param>
        /// <param name="callerLineNumber">The line number in the source file at which this method is called.</param>
        public void Log(
            LogEntry logEntry,
            [CallerMemberName] string callerMemberName = null,
            [CallerFilePath] string callerFilePath     = null,
            [CallerLineNumber] int callerLineNumber    = 0)
        {
            if (logEntry == null)
            {
                throw new ArgumentNullException(nameof(logEntry));
            }
            if (_isDisposed)
            {
                throw new ObjectDisposedException("Cannot log to a disposed Logger.");
            }
            if (LogProcessor.IsDisposed)
            {
                throw new ObjectDisposedException("Cannot log to a Logger with a disposed LogProcessor.");
            }

            if (!_canProcessLogs || logEntry.Level < Level)
            {
                return;
            }

            logEntry.CallerInfo = $"{callerFilePath}:{callerMemberName}({callerLineNumber})";

            LogProcessor.ProcessLogEntry(this, logEntry);
        }