|
| 1 | +/* |
| 2 | + Copyright The containerd Authors. |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package log |
| 18 | + |
| 19 | +import ( |
| 20 | + "context" |
| 21 | + |
| 22 | + "github.com/containerd/log" |
| 23 | +) |
| 24 | + |
| 25 | +// G is a shorthand for [GetLogger]. |
| 26 | +// |
| 27 | +// Deprecated: use [log.G]. |
| 28 | +var G = log.G |
| 29 | + |
| 30 | +// L is an alias for the standard logger. |
| 31 | +// |
| 32 | +// Deprecated: use [log.L]. |
| 33 | +var L = log.L |
| 34 | + |
| 35 | +// Fields type to pass to "WithFields". |
| 36 | +// |
| 37 | +// Deprecated: use [log.Fields]. |
| 38 | +type Fields = log.Fields |
| 39 | + |
| 40 | +// Entry is a logging entry. |
| 41 | +// |
| 42 | +// Deprecated: use [log.Entry]. |
| 43 | +type Entry = log.Entry |
| 44 | + |
| 45 | +// RFC3339NanoFixed is [time.RFC3339Nano] with nanoseconds padded using |
| 46 | +// zeros to ensure the formatted time is always the same number of |
| 47 | +// characters. |
| 48 | +// |
| 49 | +// Deprecated: use [log.RFC3339NanoFixed]. |
| 50 | +const RFC3339NanoFixed = log.RFC3339NanoFixed |
| 51 | + |
| 52 | +// Level is a logging level. |
| 53 | +// |
| 54 | +// Deprecated: use [log.Level]. |
| 55 | +type Level = log.Level |
| 56 | + |
| 57 | +// Supported log levels. |
| 58 | +const ( |
| 59 | + // TraceLevel level. |
| 60 | + // |
| 61 | + // Deprecated: use [log.TraceLevel]. |
| 62 | + TraceLevel Level = log.TraceLevel |
| 63 | + |
| 64 | + // DebugLevel level. |
| 65 | + // |
| 66 | + // Deprecated: use [log.DebugLevel]. |
| 67 | + DebugLevel Level = log.DebugLevel |
| 68 | + |
| 69 | + // InfoLevel level. |
| 70 | + // |
| 71 | + // Deprecated: use [log.InfoLevel]. |
| 72 | + InfoLevel Level = log.InfoLevel |
| 73 | + |
| 74 | + // WarnLevel level. |
| 75 | + // |
| 76 | + // Deprecated: use [log.WarnLevel]. |
| 77 | + WarnLevel Level = log.WarnLevel |
| 78 | + |
| 79 | + // ErrorLevel level |
| 80 | + // |
| 81 | + // Deprecated: use [log.ErrorLevel]. |
| 82 | + ErrorLevel Level = log.ErrorLevel |
| 83 | + |
| 84 | + // FatalLevel level. |
| 85 | + // |
| 86 | + // Deprecated: use [log.FatalLevel]. |
| 87 | + FatalLevel Level = log.FatalLevel |
| 88 | + |
| 89 | + // PanicLevel level. |
| 90 | + // |
| 91 | + // Deprecated: use [log.PanicLevel]. |
| 92 | + PanicLevel Level = log.PanicLevel |
| 93 | +) |
| 94 | + |
| 95 | +// SetLevel sets log level globally. It returns an error if the given |
| 96 | +// level is not supported. |
| 97 | +// |
| 98 | +// Deprecated: use [log.SetLevel]. |
| 99 | +func SetLevel(level string) error { |
| 100 | + return log.SetLevel(level) |
| 101 | +} |
| 102 | + |
| 103 | +// GetLevel returns the current log level. |
| 104 | +// |
| 105 | +// Deprecated: use [log.GetLevel]. |
| 106 | +func GetLevel() log.Level { |
| 107 | + return log.GetLevel() |
| 108 | +} |
| 109 | + |
| 110 | +// OutputFormat specifies a log output format. |
| 111 | +// |
| 112 | +// Deprecated: use [log.OutputFormat]. |
| 113 | +type OutputFormat = log.OutputFormat |
| 114 | + |
| 115 | +// Supported log output formats. |
| 116 | +const ( |
| 117 | + // TextFormat represents the text logging format. |
| 118 | + // |
| 119 | + // Deprecated: use [log.TextFormat]. |
| 120 | + TextFormat log.OutputFormat = "text" |
| 121 | + |
| 122 | + // JSONFormat represents the JSON logging format. |
| 123 | + // |
| 124 | + // Deprecated: use [log.JSONFormat]. |
| 125 | + JSONFormat log.OutputFormat = "json" |
| 126 | +) |
| 127 | + |
| 128 | +// SetFormat sets the log output format. |
| 129 | +// |
| 130 | +// Deprecated: use [log.SetFormat]. |
| 131 | +func SetFormat(format OutputFormat) error { |
| 132 | + return log.SetFormat(format) |
| 133 | +} |
| 134 | + |
| 135 | +// WithLogger returns a new context with the provided logger. Use in |
| 136 | +// combination with logger.WithField(s) for great effect. |
| 137 | +// |
| 138 | +// Deprecated: use [log.WithLogger]. |
| 139 | +func WithLogger(ctx context.Context, logger *log.Entry) context.Context { |
| 140 | + return log.WithLogger(ctx, logger) |
| 141 | +} |
| 142 | + |
| 143 | +// GetLogger retrieves the current logger from the context. If no logger is |
| 144 | +// available, the default logger is returned. |
| 145 | +// |
| 146 | +// Deprecated: use [log.GetLogger]. |
| 147 | +func GetLogger(ctx context.Context) *log.Entry { |
| 148 | + return log.GetLogger(ctx) |
| 149 | +} |
0 commit comments