Microsoft.Azure.WebJobs.Script.FileTraceWriter.Trace C# (CSharp) Method

Trace() public method

public Trace ( TraceEvent traceEvent ) : void
traceEvent TraceEvent
return void
        public override void Trace(TraceEvent traceEvent)
        {
            if (traceEvent == null)
            {
                throw new ArgumentNullException("traceEvent");
            }

            object value;
            if (traceEvent.Properties.TryGetValue(ScriptConstants.TracePropertyIsSystemTraceKey, out value)
                && value is bool && (bool)value)
            {
                // we don't want to write system traces to the user trace files
                return;
            }

            if (Level < traceEvent.Level || _logBuffer.Count > MaxLogLinesPerFlushInterval)
            {
                return;
            }

            if (_logBuffer.Count == MaxLogLinesPerFlushInterval)
            {
                AppendLine("Log output threshold exceeded.");
                return;
            }

            AppendLine(traceEvent.Message);

            if (traceEvent.Exception != null)
            {
                if (traceEvent.Exception is FunctionInvocationException ||
                    traceEvent.Exception is AggregateException)
                {
                    // we want to minimize the stack traces for function invocation
                    // failures, so we drill into the very inner exception, which will
                    // be the script error
                    Exception actualException = traceEvent.Exception;
                    while (actualException.InnerException != null)
                    {
                        actualException = actualException.InnerException;
                    }
                    AppendLine(actualException.Message);
                }
                else
                {
                    AppendLine(traceEvent.Exception.ToString());
                }
            }
        }