/// <summary>
        /// Writes a log entry.
        /// </summary>
        /// <typeparam name="TState">The type of the object to be written.</typeparam>
        /// <param name="logLevel">Entry will be written on this level.</param>
        /// <param name="eventId">Id of the event.</param>
        /// <param name="state">The entry to be written. Can be also an object.</param>
        /// <param name="exception">The exception related to this entry.</param>
        /// <param name="formatter">Function to create a System.String message of the state and exception.</param>
        public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            if (!IsEnabled(logLevel))
            {
                return;
            }
            _unitarySw.Stop();
            if (_autoJump)
            {
                var level = GetLevelInScope();
                if (level.HasValue && level.Value > logLevel)
                {
                    logLevel = level.Value;
                }
            }

            if (formatter != null)
            {
                var message = formatter(state, exception);
                _log.Log(logLevel, _scopeId + " - " + _unitarySw.Display(_timeUnit) + " - " + message);
            }
            else
            {
                _log.Log(logLevel, eventId, state, exception, formatter);
            }

            _unitarySw.Reset();
            _unitarySw.Start();
        }
        /// <summary>
        /// Log the total elapsed time
        /// </summary>
        public void Dispose()
        {
            var logLevel = _endLogLevel;

            if (_autoJumpContext)
            {
                var level = GetLevel();
                if (level.HasValue && level.Value > logLevel)
                {
                    logLevel = level.Value;
                }
            }

            _log?.Log(logLevel, "End {0} : Total elapsed {1}", _endContext, _scopeSw.Display(_timeUnit));
        }