Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/chassis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type (
NodeID() string
Title() string
Env() string
LogLevel() LogLevel
Reader
Writer
Entrypoint() string
Expand Down Expand Up @@ -118,6 +119,10 @@ func (c *config) Env() string {
return c.GetString("service.env")
}

func (c *config) LogLevel() LogLevel {
return ParseLogLevel(c.GetString("service.logging.level"))
}

func GetConfig() Config {
if configSingleton == nil {
LoadConfig()
Expand Down
1 change: 0 additions & 1 deletion pkg/chassis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
connectrpc.com/connect v1.16.2
connectrpc.com/grpcreflect v1.2.0
github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.15.0
github.com/envoyproxy/go-control-plane v0.12.0
github.com/hashicorp/raft v1.6.0
github.com/hashicorp/raft-boltdb/v2 v2.3.0
github.com/rs/cors v1.10.1
Expand Down
2 changes: 0 additions & 2 deletions pkg/chassis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/go-control-plane v0.12.0 h1:4X+VP1GHd1Mhj6IB5mMeGbLCleqxjletLK6K0rbxyZI=
github.com/envoyproxy/go-control-plane v0.12.0/go.mod h1:ZBTaoJ23lqITozF0M6G4/IragXCQKCnYbmlmtHvwRG0=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
Expand Down
12 changes: 7 additions & 5 deletions pkg/chassis/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package chassis
import (
"context"
"strings"

envoy "github.com/envoyproxy/go-control-plane/pkg/log"
)

// Fields is an alias primarily used for Logger methods
Expand Down Expand Up @@ -52,6 +50,9 @@ type Logger interface {
WithField(key string, value any) Logger
// WithFields - Add a map of fields to the logger.
WithFields(fields Fields) Logger
// WithCallDepth - Configures the number of frames to skip on the stack when determining the function name of the caller.
// Useful when wrapping the Logger interface for compatability with other logging interfaces.
WithCallDepth(depth int) Logger
// Trace - Definition:
// "Seriously, WTF is going on here?!?!
// I need to log every single statement I execute to find this @#$@ing memory corruption bug before I go insane"
Expand All @@ -61,23 +62,27 @@ type Logger interface {
// This is where you might log detailed information about key method parameters or
// other information that is useful for finding likely problems in specific 'problematic' areas of the code.
Debug(msg string)
Debugf(format string, args ...any)
// Info - Definition:
// Normal logging that's part of the normal operation of the app;
// diagnostic stuff so you can go back and say 'how often did this broad-level operation happen?',
// or 'how did the user's data get into this state?'
Info(msg string)
Infof(format string, args ...any)
// Warn - Definition:
// something that's concerning but not causing the operation to abort;
// # of connections in the DB pool getting low, an unusual-but-expected timeout in an operation, etc.
// Think of 'WARN' as something that's useful in aggregate; e.g. grep, group,
// and count them to get a picture of what's affecting the system health
Warn(msg string)
Warnf(format string, args ...any)
// Error - Definition:
// something that the app's doing that it shouldn't.
// This isn't a user error ('invalid search query');
// it's an assertion failure, network problem, etc etc.,
// probably one that is going to abort the current operation
Error(msg string)
Errorf(format string, args ...any)
// WrappedError - Definition:
// this is a convenience method that calls Error() but makes sure to wrap the error a final time
// so that all current call context is included in the error. This has the same output as:
Expand All @@ -97,9 +102,6 @@ type Logger interface {
// In general, only use panic for programming errors, where the stack trace is important to the context of the error.
// If the message isn't targeted at the programmer, you're simply hiding the message in superfluous data.
Panic(msg string)
// Envoy control plane logger. The `envoyproxy` had defined it's own `log.Logger` interface we are embedding here so the same abstraction
// can be used for logging in the control plane as well.
envoy.Logger
}

// ParseLogLevel takes a string level and returns the log level constant.
Expand Down