github.com/openshift-online/ocm-sdk-go@v0.1.473/logging/logger.go (about) 1 /* 2 Copyright (c) 2018 Red Hat, Inc. 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 // This file contains the definition of the logger interface that is used by the client. 18 19 package logging 20 21 import ( 22 "context" 23 ) 24 25 // Logger is the interface that must be implemented by objects that are used for logging by the 26 // client. By default the client uses a logger based on the `glog` package, but that can be changed 27 // using the `Logger` method of the builder. 28 // 29 // Note that the context is optional in most of the methods of the SDK, so implementations of this 30 // interface must accept and handle smoothly calls to the Debug, Info, Warn and Error methods where 31 // the ctx parameter is nil. 32 type Logger interface { 33 // DebugEnabled returns true if the debug level is enabled. 34 DebugEnabled() bool 35 36 // InfoEnabled returns true if the information level is enabled. 37 InfoEnabled() bool 38 39 // WarnEnabled returns true if the warning level is enabled. 40 WarnEnabled() bool 41 42 // ErrorEnabled returns true if the error level is enabled. 43 ErrorEnabled() bool 44 45 // Debug sends to the log a debug message formatted using the fmt.Sprintf function and the 46 // given format and arguments. 47 Debug(ctx context.Context, format string, args ...interface{}) 48 49 // Info sends to the log an information message formatted using the fmt.Sprintf function and 50 // the given format and arguments. 51 Info(ctx context.Context, format string, args ...interface{}) 52 53 // Warn sends to the log a warning message formatted using the fmt.Sprintf function and the 54 // given format and arguments. 55 Warn(ctx context.Context, format string, args ...interface{}) 56 57 // Error sends to the log an error message formatted using the fmt.Sprintf function and the 58 // given format and arguments. 59 Error(ctx context.Context, format string, args ...interface{}) 60 61 // Fatal sends to the log an error message formatted using the fmt.Sprintf function and the 62 // given format and arguments; and then executes an os.Exit(1) 63 // Fatal level is always enabled 64 Fatal(ctx context.Context, format string, args ...interface{}) 65 }