From ea0bd09e9e72d93778ac56b902f2d22364979fa1 Mon Sep 17 00:00:00 2001 From: Silas Davis <silas@erisindustries.com> Date: Fri, 5 May 2017 14:18:39 +0100 Subject: [PATCH] make multiline terminal output the default for cli --- config/templates.go | 24 ++++++++++++++++++++- logging/loggers/tendermint_log15_loggers.go | 7 ++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/config/templates.go b/config/templates.go index 7005ae7f..e31558ab 100644 --- a/config/templates.go +++ b/config/templates.go @@ -300,6 +300,9 @@ tendermint_host = "0.0.0.0:46657" ` +// TODO: [Silas]: before next logging release (finalising this stuff and adding +// presets) add full documentation of transforms, outputs, and their available +// configuration options. const sectionLoggingHeader = ` ################################################################################ ## @@ -308,8 +311,27 @@ const sectionLoggingHeader = ` ## Log messages are sent to one of two 'channels': info or trace ## ## They are delivered on two independent streams: 'info' or 'info and trace'. -## Each of these streams has a root +## Each of these streams has a root logging 'sink' (configured under the keys +## logging.info_sink and logging.info_and_trace_sink respectively) where each +## channels messages are delivered. +## +## A sink may optionally define any of a 'transform', an 'output', and a list of +## downstream sinks. Log messages flow through a sink by first having that +## sink's transform applied and then writing to its output and downstream sinks. +## In this way the log messages can output can be finely controlled and sent to +## a multiple different outputs having been filtered, modified, augmented, or +## labelled. This can be used to give more relevant output or to drive external +## systems. +## ## ################################################################################ +## A minimal logging config for multi-line, colourised terminal output would be: +# +# [logging] +# [logging.info_sink] +# [logging.info_and_trace_sink] +# [logging.info_and_trace_sink.output] +# output_type = "stderr" +# format = "terminal" ` diff --git a/logging/loggers/tendermint_log15_loggers.go b/logging/loggers/tendermint_log15_loggers.go index 982b232a..14b2ea09 100644 --- a/logging/loggers/tendermint_log15_loggers.go +++ b/logging/loggers/tendermint_log15_loggers.go @@ -11,7 +11,10 @@ import ( "github.com/tendermint/log15" ) -const syslogPriority = syslog.LOG_LOCAL0 +const ( + syslogPriority = syslog.LOG_LOCAL0 + defaultFormatName = "terminal" +) func NewStreamLogger(writer io.Writer, formatName string) kitlog.Logger { return log15a.Log15HandlerAsKitLogger(log15.StreamHandler(writer, @@ -49,6 +52,6 @@ func format(name string) log15.Format { case "terminal": return log15.TerminalFormat() default: - return log15.LogfmtFormat() + return format(defaultFormatName) } } -- GitLab