public void Truncate()

in src/Microsoft.Azure.WebJobs.Logging/FunctionInstanceLogItem.cs [168:220]


        public void Truncate()
        {
            // This is fundamentally driven by performance. We need to fit log entries into table rows.
            // Truncate to ensure that we're under table's maximum request payload size (4mb).
            // None of these limits (except for output log)  should actually get hit in normal scenarios. 
            this.TriggerReason = Truncate(this.TriggerReason, MaxTriggerReasonLength);
            this.ErrorDetails = Truncate(this.ErrorDetails, MaxErrorLength);

            // Logger should already have truncated this, but just in case. 
            this.LogOutput = Truncate(this.LogOutput, MaxLogOutputLength);

            // Arguments may have 1 larger argument for the trigger. 
            // The other arguments should all be small. 
            if (this.Arguments != null)
            {
                bool truncate = false;
                int argSize = 0;
                foreach (var kv in this.Arguments)
                {
                    argSize += kv.Key.Length;
                    if (!string.IsNullOrEmpty(kv.Value))
                    {
                        if (kv.Value.Length > MaxParameterPayloadLength)
                        {
                            truncate = true;
                            argSize += MaxParameterPayloadLength;
                        }
                        else
                        {
                            argSize += kv.Value.Length;
                        }
                    }
                }

                if (argSize > MaxParameterTotalPayloadLength)
                {
                    // This shouldn't happen in any normal case. 
                    // We'd need either a) a very large number of individual parameters; 
                    // b) multiple parameters (not just the trigger) with large payloads.
                    // At this point, we can't log all that, so just truncate. 
                    this.Arguments = null;
                }
                else if (truncate)
                {
                    Dictionary<string, string> args2 = new Dictionary<string, string>();
                    foreach (var kv in this.Arguments)
                    {
                        args2[kv.Key] = Truncate(kv.Value, MaxParameterPayloadLength);
                    }
                    this.Arguments = args2;
                }
            }
        }