Documentation ¶
Overview ¶
(C) Copyright 2019 Intel Corporation.
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.
GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.
(C) Copyright 2019 Intel Corporation.
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.
GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.
(C) Copyright 2019 Intel Corporation.
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.
GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.
(C) Copyright 2019 Intel Corporation.
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.
GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.
(C) Copyright 2019 Intel Corporation.
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.
GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.
(C) Copyright 2019 Intel Corporation.
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.
GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.
(C) Copyright 2019 Intel Corporation.
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.
GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.
(C) Copyright 2019 Intel Corporation.
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.
GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.
Index ¶
- Constants
- func MustCreateSyslogger(prio syslog.Priority, flags int) *log.Logger
- func NewTestLogger(prefix string) (*LeveledLogger, *LogBuffer)
- type DebugLogger
- type DefaultDebugLogger
- type DefaultErrorLogger
- type DefaultInfoLogger
- type ErrorLogger
- type InfoLogger
- type JSONFormatter
- type LeveledLogger
- func (ll *LeveledLogger) AddDebugLogger(newLogger DebugLogger)
- func (ll *LeveledLogger) AddErrorLogger(newLogger ErrorLogger)
- func (ll *LeveledLogger) AddInfoLogger(newLogger InfoLogger)
- func (ll *LeveledLogger) Debug(msg string)
- func (ll *LeveledLogger) Debugf(format string, args ...interface{})
- func (ll *LeveledLogger) Error(msg string)
- func (ll *LeveledLogger) Errorf(format string, args ...interface{})
- func (ll *LeveledLogger) Info(msg string)
- func (ll *LeveledLogger) Infof(format string, args ...interface{})
- func (ll *LeveledLogger) Level() LogLevel
- func (ll *LeveledLogger) SetLevel(newLevel LogLevel)
- func (ll *LeveledLogger) WithDebugLogger(newLogger DebugLogger) *LeveledLogger
- func (ll *LeveledLogger) WithErrorLogger(newLogger ErrorLogger) *LeveledLogger
- func (ll *LeveledLogger) WithInfoLogger(newLogger InfoLogger) *LeveledLogger
- func (ll *LeveledLogger) WithJSONOutput() *LeveledLogger
- func (ll *LeveledLogger) WithLogLevel(level LogLevel) *LeveledLogger
- func (ll *LeveledLogger) WithSyslogOutput() *LeveledLogger
- type LogBuffer
- type LogLevel
- type Logger
- type Outputter
Constants ¶
const (
DefaultLogLevel = LogLevelInfo
)
Variables ¶
This section is empty.
Functions ¶
func MustCreateSyslogger ¶
MustCreateSyslogger attempts to create a *log.Logger configured for output to the system log daemon. If it fails, it will panic.
func NewTestLogger ¶
func NewTestLogger(prefix string) (*LeveledLogger, *LogBuffer)
NewTestLogger returns a logger and a *LogBuffer, with the logger configured to send all output into the buffer. The logger's level is set to DEBUG by default.
Types ¶
type DebugLogger ¶
type DebugLogger interface {
Debugf(format string, args ...interface{})
}
DebugLogger defines an interface to be implemented by Debug loggers.
type DefaultDebugLogger ¶
type DefaultDebugLogger struct {
// contains filtered or unexported fields
}
DefaultDebugLogger implements the DebugLogger interface.
func NewDebugLogger ¶
func NewDebugLogger(dest io.Writer) *DefaultDebugLogger
NewDebugLogger returns a DebugLogger configured for outputting debugging messages.
func (*DefaultDebugLogger) Debugf ¶
func (l *DefaultDebugLogger) Debugf(format string, args ...interface{})
Debugf emits a formatted debug message.
func (*DefaultDebugLogger) WithJSONOutput ¶
func (l *DefaultDebugLogger) WithJSONOutput() DebugLogger
WithJSONOutput switches the logger's output to use structured JSON formatting.
func (*DefaultDebugLogger) WithSyslogOutput ¶
func (l *DefaultDebugLogger) WithSyslogOutput() DebugLogger
WithSyslogOutput switches the logger's output to emit messages via the system logging service.
type DefaultErrorLogger ¶
type DefaultErrorLogger struct {
// contains filtered or unexported fields
}
DefaultErrorLogger implements the ErrorLogger interface.
func NewCommandLineErrorLogger ¶
func NewCommandLineErrorLogger(output io.Writer) *DefaultErrorLogger
NewCommandLineErrorLogger returns an ErrorLogger configured for outputting unadorned error messages (i.e. no timestamps, source info, etc); typically used for CLI utility logging.
func NewErrorLogger ¶
func NewErrorLogger(prefix string, output io.Writer) *DefaultErrorLogger
NewErrorLogger returns an ErrorLogger configured for outputting error messages with standard formatting (e.g. to stderr, logfile, etc.)
func (*DefaultErrorLogger) Errorf ¶
func (l *DefaultErrorLogger) Errorf(format string, args ...interface{})
Errorf emits a formatted error message.
func (*DefaultErrorLogger) WithJSONOutput ¶
func (l *DefaultErrorLogger) WithJSONOutput() ErrorLogger
WithJSONOutput switches the logger's output to use structured JSON formatting.
func (*DefaultErrorLogger) WithSyslogOutput ¶
func (l *DefaultErrorLogger) WithSyslogOutput() ErrorLogger
WithSyslogOutput switches the logger's output to emit messages via the system logging service.
type DefaultInfoLogger ¶
type DefaultInfoLogger struct {
// contains filtered or unexported fields
}
DefaultInfoLogger implements the InfoLogger interface.
func NewCommandLineInfoLogger ¶
func NewCommandLineInfoLogger(output io.Writer) *DefaultInfoLogger
NewCommandLineInfoLogger returns an InfoLogger configured for outputting unadorned informational messages (i.e. no timestamps, source info, etc); typically used for CLI utility logging.
func NewInfoLogger ¶
func NewInfoLogger(prefix string, output io.Writer) *DefaultInfoLogger
NewInfoLogger returns an InfoLogger configured for outputting informational messages with standard formatting (e.g. to stderr, logfile, etc.)
func (*DefaultInfoLogger) Infof ¶
func (l *DefaultInfoLogger) Infof(format string, args ...interface{})
Infof emits a formatted informational message.
func (*DefaultInfoLogger) WithJSONOutput ¶
func (l *DefaultInfoLogger) WithJSONOutput() InfoLogger
WithJSONOutput switches the logger's output to use structured JSON formatting.
func (*DefaultInfoLogger) WithSyslogOutput ¶
func (l *DefaultInfoLogger) WithSyslogOutput() InfoLogger
WithSyslogOutput switches the logger's output to emit messages via the system logging service.
type ErrorLogger ¶
type ErrorLogger interface {
Errorf(format string, args ...interface{})
}
ErrorLogger defines an interface to be implemented by Error loggers.
type InfoLogger ¶
type InfoLogger interface {
Infof(format string, args ...interface{})
}
InfoLogger defines an interface to be implemented by Info loggers.
type JSONFormatter ¶
type JSONFormatter struct {
// contains filtered or unexported fields
}
JSONFormatter emits JSON-formatted log output
func NewJSONFormatter ¶
func NewJSONFormatter(output io.Writer, level, extraData string, flags int) *JSONFormatter
NewJSONFormatter returns a *JSONFormatter configured to emit JSON-formatted output.
type LeveledLogger ¶
LeveledLogger provides a logging implementation which can emit log messages to multiple destinations with different output formats.
func NewCombinedLogger ¶
func NewCombinedLogger(prefix string, output io.Writer) *LeveledLogger
NewCombinedLogger returns a logger configured to send all output to the supplied io.Writer.
func NewCommandLineLogger ¶
func NewCommandLineLogger() *LeveledLogger
NewCommandLineLogger returns a logger configured to send non-error output to stdout and error output to stderr. The output format is suitable for command line utilities which don't want output to include timestamps and filenames.
func NewStdoutLogger ¶
func NewStdoutLogger(prefix string) *LeveledLogger
NewStdoutLogger returns a logger configured to send all output to stdout (suitable for containerized/systemd operation).
func (*LeveledLogger) AddDebugLogger ¶
func (ll *LeveledLogger) AddDebugLogger(newLogger DebugLogger)
AddDebugLogger adds the specified Debug logger to the logger.
func (*LeveledLogger) AddErrorLogger ¶
func (ll *LeveledLogger) AddErrorLogger(newLogger ErrorLogger)
AddErrorLogger adds the specified Error logger to the logger.
func (*LeveledLogger) AddInfoLogger ¶
func (ll *LeveledLogger) AddInfoLogger(newLogger InfoLogger)
AddInfoLogger adds the specified Info logger to the logger.
func (*LeveledLogger) Debug ¶
func (ll *LeveledLogger) Debug(msg string)
Debug emits an unformatted message at Debug level, if the logger is configured to do so.
func (*LeveledLogger) Debugf ¶
func (ll *LeveledLogger) Debugf(format string, args ...interface{})
Debugf emits a formatted message at Debug level, if the logger is configured to do so.
func (*LeveledLogger) Error ¶
func (ll *LeveledLogger) Error(msg string)
Error emits an unformatted message at Error level, if the logger is configured to do so.
func (*LeveledLogger) Errorf ¶
func (ll *LeveledLogger) Errorf(format string, args ...interface{})
Errorf emits a formatted message at Error level, if the logger is configured to do so.
func (*LeveledLogger) Info ¶
func (ll *LeveledLogger) Info(msg string)
Info emits an unformatted message at Info level, if the logger is configured to do so.
func (*LeveledLogger) Infof ¶
func (ll *LeveledLogger) Infof(format string, args ...interface{})
Infof emits a formatted message at Info level, if the logger is configured to do so.
func (*LeveledLogger) Level ¶
func (ll *LeveledLogger) Level() LogLevel
Level returns the logger's current LogLevel.
func (*LeveledLogger) SetLevel ¶
func (ll *LeveledLogger) SetLevel(newLevel LogLevel)
SetLevel sets the logger's LogLevel, at or above which messages will be emitted.
func (*LeveledLogger) WithDebugLogger ¶
func (ll *LeveledLogger) WithDebugLogger(newLogger DebugLogger) *LeveledLogger
WithDebugLogger adds the specified Debug logger to the logger as part of a chained method call.
func (*LeveledLogger) WithErrorLogger ¶
func (ll *LeveledLogger) WithErrorLogger(newLogger ErrorLogger) *LeveledLogger
WithErrorLogger adds the specified Error logger to the logger as part of a chained method call.
func (*LeveledLogger) WithInfoLogger ¶
func (ll *LeveledLogger) WithInfoLogger(newLogger InfoLogger) *LeveledLogger
WithInfoLogger adds the specified Info logger to the logger as part of a chained method call.
func (*LeveledLogger) WithJSONOutput ¶
func (ll *LeveledLogger) WithJSONOutput() *LeveledLogger
WithJSONOutput is a convenience method to set all logging outputs to the JSON formatter.
func (*LeveledLogger) WithLogLevel ¶
func (ll *LeveledLogger) WithLogLevel(level LogLevel) *LeveledLogger
WithLogLevel allows the logger's LogLevel to be set as part of a chained method call.
func (*LeveledLogger) WithSyslogOutput ¶
func (ll *LeveledLogger) WithSyslogOutput() *LeveledLogger
WithSyslogOutput is a convenience method to set all logging outputs to the Syslog formatter.
type LogBuffer ¶
LogBuffer provides a thread-safe wrapper for bytes.Buffer. It only wraps a subset of bytes.Buffer's methods; just enough to implement io.Reader, io.Writer, and fmt.Stringer. The Reset() method is also wrapped in order to make it useful for testing.
type LogLevel ¶
type LogLevel int32
LogLevel represents the level at which the logger will emit log messages
type Logger ¶
type Logger interface { DebugLogger Debug(msg string) InfoLogger Info(msg string) ErrorLogger Error(msg string) }
Logger defines a standard logging interface