[lxc-devel] [lxd/master] shared/logging: Export LogfmtFormat

stgraber on Github lxc-bot at linuxcontainers.org
Tue May 2 02:04:33 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 406 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170502/160c8232/attachment.bin>
-------------- next part --------------
From ad52e51e6f09dc357bd87a30a19dcc7a62e58888 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 1 May 2017 21:57:44 -0400
Subject: [PATCH] shared/logging: Export LogfmtFormat
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

I'd like to use it in another project of mine :)

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 shared/logging/format.go | 3 ++-
 shared/logging/log.go    | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/shared/logging/format.go b/shared/logging/format.go
index 93ddda6..d60b7e4 100644
--- a/shared/logging/format.go
+++ b/shared/logging/format.go
@@ -67,7 +67,8 @@ func TerminalFormat() log.Format {
 	})
 }
 
-func logfmtFormat() log.Format {
+// LogfmtFormat return a formatter for a text log file
+func LogfmtFormat() log.Format {
 	return log.FormatFunc(func(r *log.Record) []byte {
 		common := []interface{}{r.KeyNames.Time, r.Time, r.KeyNames.Lvl, r.Lvl, r.KeyNames.Msg, r.Msg}
 		buf := &bytes.Buffer{}
diff --git a/shared/logging/log.go b/shared/logging/log.go
index 8d6bf2a..8602341 100644
--- a/shared/logging/log.go
+++ b/shared/logging/log.go
@@ -19,7 +19,7 @@ func GetLogger(syslog string, logfile string, verbose bool, debug bool, customHa
 	var syshandler log.Handler
 
 	// Format handler
-	format := logfmtFormat()
+	format := LogfmtFormat()
 	if term.IsTty(os.Stderr.Fd()) {
 		format = TerminalFormat()
 	}


More information about the lxc-devel mailing list