public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            if (!IsEnabled(logLevel))
            {
                return;
            }

            if (state is IDictionary <string, object> stateInfo && IsDiagnosticEvent(stateInfo))
            {
                string message = formatter(state, exception);
                if (_diagnosticEventRepository == null)
                {
                    _diagnosticEventRepository = _diagnosticEventRepositoryFactory.Create();
                }
                _diagnosticEventRepository.WriteDiagnosticEvent(DateTime.UtcNow, stateInfo[ScriptConstants.ErrorCodeKey].ToString(), logLevel, message, stateInfo[ScriptConstants.HelpLinkKey].ToString(), exception);
            }
        }
 public TestDiagnosticEventRepositoryFactory(IDiagnosticEventRepository repository)
 {
     _repository = repository;
 }