From 7fb9fde094defee8209b065d3b06582431c7bb27 Mon Sep 17 00:00:00 2001 From: "sudesh.shetty" Date: Wed, 24 Jul 2019 17:22:05 -0400 Subject: [PATCH] feat: logging interface -provided logging interface -log levels supported - CRITICAL, ERROR, WARNING, INFO, DEBUG, where INFO is default logging level -logging provider implementation can be used to provide custom logging provider -resolves #21 Signed-off-by: sudesh.shetty --- pkg/common/log/api.go | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 pkg/common/log/api.go diff --git a/pkg/common/log/api.go b/pkg/common/log/api.go new file mode 100644 index 0000000000..0a5e78e5c5 --- /dev/null +++ b/pkg/common/log/api.go @@ -0,0 +1,46 @@ +/* +Copyright SecureKey Technologies Inc. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package log + +// Level defines all available log levels for logging messages. +type Level int + +// Log levels. +const ( + CRITICAL Level = iota + ERROR + WARNING + INFO //default logging level + DEBUG +) + +//Logger - Standard logger interface +type Logger interface { + + //Fatalf is critical fatal logging, should possibly followed by a call to os.Exit(1) + Fatalf(msg string, args ...interface{}) + + //Panicf is critical logging, should possibly followed by panic + Panicf(msg string, args ...interface{}) + + //Debugf is for logging verbose messages + Debugf(msg string, args ...interface{}) + + //Infof for logging general logging messages + Infof(msg string, args ...interface{}) + + //Warnf is for logging messages about possible issues + Warnf(msg string, args ...interface{}) + + //Errorf is for logging errors + Errorf(msg string, args ...interface{}) +} + +// LoggerProvider is a factory for moduled loggers +type LoggerProvider interface { + GetLogger(module string) Logger +}