public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            IEnumerable <KeyValuePair <string, object> > properties = state as IEnumerable <KeyValuePair <string, object> >;
            string formattedMessage = formatter?.Invoke(state, exception);

            // If we have no structured data and no message, there's nothing to log
            if ((string.IsNullOrEmpty(formattedMessage) && properties == null) ||
                !IsEnabled(logLevel) || IsFromTraceWriter(properties))
            {
                return;
            }

            TraceLevel traceLevel   = GetTraceLevel(logLevel);
            TraceEvent traceEvent   = new TraceEvent(traceLevel, formattedMessage, _categoryName, exception);
            string     functionName = GetFunctionName();

            // If we don't have a function name, we have no way to create a TraceWriter
            if (functionName == null)
            {
                return;
            }

            TraceWriter traceWriter = _traceWriterFactory.Create(functionName);

            traceWriter.Trace(traceEvent);
        }
        public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            IEnumerable <KeyValuePair <string, object> > properties = state as IEnumerable <KeyValuePair <string, object> >;
            string formattedMessage = formatter?.Invoke(state, exception);

            // If we have no structured data and no message, there's nothing to log
            if ((string.IsNullOrEmpty(formattedMessage) && properties == null) ||
                !IsEnabled(logLevel))
            {
                return;
            }

            TraceEvent traceEvent = new TraceEvent(logLevel.ToTraceLevel(), formattedMessage, _categoryName, exception);

            TraceWriter traceWriter = _traceWriterFactory.Create(_language, "Worker");

            traceWriter.Trace(traceEvent);
        }