-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable JSON formatted logs if env var is set
- Loading branch information
Showing
9 changed files
with
127 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,35 @@ | ||
module github.com/edgelesssys/ego/ego | ||
|
||
go 1.20 | ||
go 1.23.3 | ||
|
||
require ( | ||
github.com/edgelesssys/marblerun v1.4.1 | ||
github.com/edgelesssys/marblerun v1.6.1-0.20241120142109-82ce1218cbc5 | ||
github.com/google/go-cmp v0.6.0 | ||
github.com/klauspost/cpuid/v2 v2.2.8 | ||
github.com/klauspost/cpuid/v2 v2.2.9 | ||
github.com/spf13/afero v1.11.0 | ||
github.com/spf13/cobra v1.8.1 | ||
github.com/stretchr/testify v1.9.0 | ||
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e | ||
google.golang.org/grpc v1.64.1 | ||
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f | ||
google.golang.org/grpc v1.68.0 | ||
) | ||
|
||
require ( | ||
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect | ||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
github.com/edgelesssys/ego v1.5.2 // indirect | ||
github.com/edgelesssys/era v0.3.3 // indirect | ||
github.com/edgelesssys/ego v1.6.0 // indirect | ||
github.com/go-jose/go-jose/v4 v4.0.4 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
go.uber.org/multierr v1.11.0 // indirect | ||
go.uber.org/zap v1.27.0 // indirect | ||
golang.org/x/crypto v0.28.0 // indirect | ||
golang.org/x/net v0.30.0 // indirect | ||
golang.org/x/sys v0.26.0 // indirect | ||
golang.org/x/text v0.19.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 // indirect | ||
google.golang.org/protobuf v1.34.2 // indirect | ||
gopkg.in/square/go-jose.v2 v2.6.0 // indirect | ||
golang.org/x/crypto v0.29.0 // indirect | ||
golang.org/x/net v0.31.0 // indirect | ||
golang.org/x/sys v0.27.0 // indirect | ||
golang.org/x/text v0.20.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect | ||
google.golang.org/protobuf v1.35.2 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Edgeless Systems GmbH. | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
package config | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
) | ||
|
||
var LogJSON = strings.EqualFold(os.Getenv("EDG_LOG_FORMAT"), "json") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) Edgeless Systems GmbH. | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
package launch | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"log/slog" | ||
"regexp" | ||
) | ||
|
||
var rxLogTag = regexp.MustCompile(`^\[(erthost|ego)\] `) | ||
|
||
// jsonifier is a writer that rewrites ert/ego log messages to JSON. | ||
type jsonifier struct { | ||
out io.Writer | ||
log *slog.Logger | ||
buf []byte | ||
} | ||
|
||
func newJsonifier(out io.Writer) *jsonifier { | ||
return &jsonifier{ | ||
out: out, | ||
log: slog.New(slog.NewJSONHandler(out, nil)), | ||
} | ||
} | ||
|
||
func (j *jsonifier) Write(p []byte) (int, error) { | ||
buf := append(j.buf, p...) | ||
|
||
// write out all complete lines in buf | ||
for { | ||
idx := bytes.IndexByte(buf, '\n') | ||
if idx == -1 { | ||
break | ||
} | ||
|
||
// use JSON logger if line begins with known tag | ||
if rxLogTag.Match(buf[:idx]) { | ||
j.log.Info(string(buf[:idx])) | ||
} else { | ||
_, _ = j.out.Write(buf[:idx+1]) | ||
} | ||
|
||
buf = buf[idx+1:] | ||
} | ||
|
||
j.buf = buf | ||
return len(p), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters