[lxc-devel] [lxd/master] lxd: Add pretty logging function
monstermunchkin on Github
lxc-bot at linuxcontainers.org
Mon Aug 12 12:15:13 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 415 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190812/7f44fad0/attachment.bin>
-------------- next part --------------
From 8c6748704f29c33dba9b697ddd68ce0214510c0c Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Thu, 2 May 2019 14:46:17 +0200
Subject: [PATCH] lxd: Add pretty logging function
Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
lxd/logging.go | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lxd/logging.go b/lxd/logging.go
index 15b8ccf1f3..62e163cc0d 100644
--- a/lxd/logging.go
+++ b/lxd/logging.go
@@ -147,3 +147,19 @@ func expireLogs(ctx context.Context, state *state.State) error {
return nil
}
+
+func logAction(infoMsg, successMsg, errorMsg string, ctx *log.Ctx, success *bool, err *error) func() {
+ logger.Info(infoMsg, *ctx)
+
+ return func() {
+ if *success {
+ logger.Info(successMsg, *ctx)
+ } else {
+ if (*err) != nil {
+ (*ctx)["error"] = (*err).Error()
+ }
+
+ logger.Error(errorMsg, *ctx)
+ }
+ }
+}
More information about the lxc-devel
mailing list