-
Notifications
You must be signed in to change notification settings - Fork 0
Add LogFormatContainer and LogLevelContainer for exposing the configured LogFormat and LogLevel
#7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,7 +81,7 @@ func NewNameContainer(baseContainer app.Container, appName string) (NameContaine | |
| return newNameContainer(baseContainer, appName) | ||
| } | ||
|
|
||
| // LoggerContainer provides a *slog.Logger. | ||
| // LoggerContainer provides the *slog.Logger set for the Container. | ||
| type LoggerContainer interface { | ||
| Logger() *slog.Logger | ||
| } | ||
|
|
@@ -91,20 +91,46 @@ func NewLoggerContainer(logger *slog.Logger) LoggerContainer { | |
| return newLoggerContainer(logger) | ||
| } | ||
|
|
||
| // LogLevelContainer provides the LogLevel set for the Container. | ||
| type LogLevelContainer interface { | ||
| LogLevel() LogLevel | ||
| } | ||
|
|
||
| // NewLogLevelContainer returns a new LogLevelContainer. | ||
| func NewLogLevelContainer(logLevel LogLevel) LogLevelContainer { | ||
| return newLogLevelContainer(logLevel) | ||
| } | ||
|
|
||
| // LogFormatContainer provides the LogFormat set for the Container. | ||
| type LogFormatContainer interface { | ||
| LogFormat() LogFormat | ||
| } | ||
|
|
||
| // NewLogFormatContainer returns a new LogFormatContainer. | ||
| func NewLogFormatContainer(logFormat LogFormat) LogFormatContainer { | ||
| return newLogFormatContainer(logFormat) | ||
| } | ||
|
|
||
| // Container contains not just the base app container, but all extended containers. | ||
| type Container interface { | ||
| NameContainer | ||
| LoggerContainer | ||
| LogLevelContainer | ||
| LogFormatContainer | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strictly speaking, this is all a breaking change, can you explain a bit more why you need this?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My use-case specifically is for rendering the report from our compiler. I'd like to pass on configurations from the CLI framework so that |
||
| } | ||
|
|
||
| // NewContainer returns a new Container. | ||
| func NewContainer( | ||
| nameContainer NameContainer, | ||
| logger *slog.Logger, | ||
| logLevel LogLevel, | ||
| logFormat LogFormat, | ||
| ) Container { | ||
| return newContainer( | ||
| nameContainer, | ||
| logger, | ||
| logLevel, | ||
| logFormat, | ||
| ) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Copyright 2025 Buf Technologies, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package appext | ||
|
|
||
| type logFormatContainer struct { | ||
| logFormat LogFormat | ||
| } | ||
|
|
||
| func newLogFormatContainer(logFormat LogFormat) *logFormatContainer { | ||
| return &logFormatContainer{ | ||
| logFormat: logFormat, | ||
| } | ||
| } | ||
|
|
||
| func (c *logFormatContainer) LogFormat() LogFormat { | ||
| return c.logFormat | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Copyright 2025 Buf Technologies, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package appext | ||
|
|
||
| type logLevelContainer struct { | ||
| logLevel LogLevel | ||
| } | ||
|
|
||
| func newLogLevelContainer(logLevel LogLevel) *logLevelContainer { | ||
| return &logLevelContainer{ | ||
| logLevel: logLevel, | ||
| } | ||
| } | ||
|
|
||
| func (c *logLevelContainer) LogLevel() LogLevel { | ||
| return c.logLevel | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No Godoc