in agent/logging/agent_logging_envoy_formatter.go [33:85]
func (f *AgentEnvoyLogFormatter) Format(entry *log.Entry) ([]byte, error) {
// Format the message to the glog format
// Reference https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/application_logging.htm
// '%L%m%d %T.%e %t envoy] [%t][%n]%v' produces
// [2021-10-20 16:25:59.915][72][debug][pool] [source/common/conn_pool/conn_pool_base.cc:175] [C4] creating stream
var output string
// Date and Time
y, m, d := entry.Time.UTC().Date()
output += fmt.Sprintf("[%04d-%02d-%02d %02d:%02d:%02d.%03d]",
y, m, d,
entry.Time.UTC().Hour(),
entry.Time.UTC().Minute(),
entry.Time.UTC().Second(),
entry.Time.UTC().Nanosecond()/int(time.Millisecond),
)
// Process ID
output += fmt.Sprintf("[%d]", f.currentPid)
// Log Level
output += fmt.Sprintf("[%s] [%s] ", strings.ToLower(entry.Level.String()), config.AGENT_LOG_IDENTIFIER)
// Log Message
output += entry.Message
// Map seems to be empty, however append the entries to the end of the log message
var keyValuePairs string
if len(entry.Data) > 0 {
for k, v := range entry.Data {
if keyValuePairs != "" {
keyValuePairs += ","
}
keyValuePairs += fmt.Sprintf("Key: %s: Value %v\n", k, v)
}
if keyValuePairs != "" {
output += fmt.Sprintf("[%s]", keyValuePairs)
}
}
var b *bytes.Buffer
if entry.Buffer != nil {
b = entry.Buffer
} else {
b = &bytes.Buffer{}
}
output += "\n"
b.WriteString(output)
return b.Bytes(), nil
}