2023-01-05 17:11:59 +08:00
|
|
|
From 5584140c9549c2c9c6a0b0c5afea0850d1e88926 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: zhongjiawei <zhongjiawei1@huawei.com>
|
|
|
|
|
Date: Thu, 5 Jan 2023 16:32:43 +0800
|
2022-10-26 16:13:47 +08:00
|
|
|
Subject: [PATCH] runc: fix runc log decode failed
|
|
|
|
|
|
|
|
|
|
---
|
2023-01-05 17:11:59 +08:00
|
|
|
main.go | 21 ++++++++++++++++++++-
|
2022-10-26 16:13:47 +08:00
|
|
|
1 file changed, 20 insertions(+), 1 deletion(-)
|
|
|
|
|
|
2023-01-05 17:11:59 +08:00
|
|
|
diff --git a/main.go b/main.go
|
2022-10-26 16:13:47 +08:00
|
|
|
index 0a6f3b4..6e9101a 100644
|
2023-01-05 17:11:59 +08:00
|
|
|
--- a/main.go
|
|
|
|
|
+++ b/main.go
|
2022-10-26 16:13:47 +08:00
|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
+ "encoding/json"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io"
|
|
|
|
|
@@ -10,6 +11,7 @@ import (
|
|
|
|
|
"runtime"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
+ "time"
|
|
|
|
|
|
|
|
|
|
"github.com/opencontainers/runc/libcontainer/seccomp"
|
|
|
|
|
"github.com/opencontainers/runtime-spec/specs-go"
|
|
|
|
|
@@ -219,7 +221,7 @@ func configLogrus(context *cli.Context) error {
|
|
|
|
|
logrus.SetOutput(f)
|
|
|
|
|
hook, serr := logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO|syslog.LOG_USER, "docker-runc")
|
|
|
|
|
if serr != nil {
|
|
|
|
|
- fmt.Fprint(f, fmt.Sprintf("Leo: new syslog hook get %s", serr))
|
|
|
|
|
+ logToFile(f, "error", fmt.Sprintf("Leo: new syslog hook get %s", serr))
|
|
|
|
|
} else {
|
|
|
|
|
logrus.AddHook(hook)
|
|
|
|
|
}
|
|
|
|
|
@@ -238,3 +240,20 @@ func configLogrus(context *cli.Context) error {
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func logToFile(f io.Writer, level string, msg string) {
|
|
|
|
|
+ var (
|
|
|
|
|
+ log struct {
|
|
|
|
|
+ Level string
|
|
|
|
|
+ Msg string
|
|
|
|
|
+ Time time.Time
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ log.Level = level
|
|
|
|
|
+ log.Msg = msg
|
|
|
|
|
+ log.Time = time.Now()
|
|
|
|
|
+ s, err := json.Marshal(log)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ fmt.Fprint(f, string(s))
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
--
|
|
|
|
|
2.30.0
|
|
|
|
|
|