From 6ca27f5d49a3dce28ff4fbff1d2cf44caaa464ce Mon Sep 17 00:00:00 2001 From: "sudesh.shetty" Date: Mon, 29 Jul 2019 16:40:54 -0400 Subject: [PATCH] feat: default logger implementation - defLog : default implementation of moduled logger built on top of go 'log' package. - modLog: moduled level based logger implementation wrapping custom logger implementation. - Story: #21 Signed-off-by: sudesh.shetty --- pkg/internal/common/logging/modlog/deflog.go | 157 +++++++++++++++ .../common/logging/modlog/deflog_test.go | 22 +++ .../common/logging/modlog/logtestutils.go | 183 ++++++++++++++++++ pkg/internal/common/logging/modlog/modlog.go | 65 +++++++ .../common/logging/modlog/modlog_test.go | 17 ++ .../common/logging/modlog/provider.go | 49 +++++ .../common/logging/modlog/provider_test.go | 49 +++++ 7 files changed, 542 insertions(+) create mode 100644 pkg/internal/common/logging/modlog/deflog.go create mode 100644 pkg/internal/common/logging/modlog/deflog_test.go create mode 100644 pkg/internal/common/logging/modlog/logtestutils.go create mode 100644 pkg/internal/common/logging/modlog/modlog.go create mode 100644 pkg/internal/common/logging/modlog/modlog_test.go create mode 100644 pkg/internal/common/logging/modlog/provider.go create mode 100644 pkg/internal/common/logging/modlog/provider_test.go diff --git a/pkg/internal/common/logging/modlog/deflog.go b/pkg/internal/common/logging/modlog/deflog.go new file mode 100644 index 0000000000..b0420fff61 --- /dev/null +++ b/pkg/internal/common/logging/modlog/deflog.go @@ -0,0 +1,157 @@ +/* +Copyright SecureKey Technologies Inc. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package modlog + +import ( + "fmt" + "io" + "log" + "os" + "path/filepath" + "runtime" + "strings" + + "github.com/hyperledger/aries-framework-go/pkg/internal/common/logging/metadata" + + logapi "github.com/hyperledger/aries-framework-go/pkg/common/log" +) + +const ( + logLevelFormatter = "UTC %s-> %s " + logPrefixFormatter = " [%s] " + callerInfoFormatter = "- %s " +) + +// defLog is a logger implementation built on top of standard go log. +// This is moduled logger where each module can have different logging levels (default is INFO). +// There is a configurable caller info feature which displays caller function information name in logged lines. +// caller info can be configured by log levels and modules. By default it is enabled. +// Log Format : []