This repository was archived by the owner on Jan 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
verbose output #46
Open
xiekeyang
wants to merge
2
commits into
opencontainers:master
Choose a base branch
from
xiekeyang:verbose
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
verbose output #46
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,31 @@ | ||
| // Copyright 2016 The Linux Foundation | ||
| // | ||
| // 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 logger | ||
|
|
||
| import ( | ||
| "context" | ||
| ) | ||
|
|
||
| // Context is a copy of Context from the stdlib context package. | ||
| type Context interface { | ||
|
Contributor
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. Do not define a new context type. |
||
| context.Context | ||
| } | ||
|
|
||
| // Background returns a non-nil, empty Context. The background context | ||
| // provides a single key, "instance.id" that is globally unique to the | ||
| // process. | ||
| func Background() context.Context { | ||
| return context.Background() | ||
| } | ||
This file contains hidden or 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,69 @@ | ||
| // Copyright 2016 The Linux Foundation | ||
| // | ||
| // 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 logger | ||
|
Contributor
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. What is the purpose of this package?
Contributor
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. Here is an example of a context-integrated logger that is threadsafe: https://github.com/docker/containerd/blob/master/log/context.go#L28. However, please let me know what the intent of this package and we can get it into shape. |
||
|
|
||
| import ( | ||
| // TODO(xiekeyang): The adaptation should be checked for openSUSE | ||
| // on non-x86_64 architectures. If encounting problem, the golang | ||
| // version should be updated accordingly. | ||
| "context" | ||
| "os" | ||
|
|
||
| "github.com/Sirupsen/logrus" | ||
| ) | ||
|
|
||
| var ( | ||
| // G is an alias for GetLogger. | ||
| // | ||
| // We may want to define this locally to a package to get package tagged log | ||
| // messages. | ||
| G = GetLogger | ||
|
|
||
| // LogEntry provides a public and standard logger instance. | ||
| LogEntry = logrus.NewEntry(logrus.StandardLogger()) | ||
| ) | ||
|
|
||
| type ( | ||
| loggerKey struct{} | ||
| ) | ||
|
|
||
| // WithLogger returns a new context with the provided logger. Use in | ||
| // combination with logger.WithField(s) for great effect. | ||
| func WithLogger(ctx context.Context, logger *logrus.Entry) context.Context { | ||
| return context.WithValue(ctx, loggerKey{}, logger) | ||
| } | ||
|
|
||
| // GetLogger retrieves the current logger from the context. If no logger is | ||
| // available, the default logger is returned. | ||
| func GetLogger(ctx context.Context) *logrus.Entry { | ||
| logger := ctx.Value(loggerKey{}) | ||
|
|
||
| if logger == nil { | ||
| return LogEntry | ||
| } | ||
|
|
||
| return logger.(*logrus.Entry) | ||
| } | ||
|
|
||
| // EnableDebugMode enables a selectable debug mode. | ||
| func EnableDebugMode(debug bool) { | ||
| if debug { | ||
| LogEntry.Logger.Level = logrus.DebugLevel | ||
| } | ||
| } | ||
|
|
||
| func init() { | ||
| LogEntry.Logger.Out = os.Stderr | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This doesn't make sense. This should just use a regular context. Don't define a new
Contexttype.Please follow the pattern in
containerd. It is well-healed and does exactly what is needed here.