refactor: refactoring of code to meet all golangci-lint requirements
This commit is contained in:
@@ -55,7 +55,7 @@ func Fatal(msg string, args ...interface{}) {
|
||||
func Debug(msg string, args ...interface{}) {
|
||||
log.SetOutput(getStd(util.GetStringEnv("GOMA_ACCESS_LOG", "/dev/stdout")))
|
||||
logLevel := util.GetStringEnv("GOMA_LOG_LEVEL", "")
|
||||
if strings.ToLower(logLevel) == "trace" || strings.ToLower(logLevel) == "debug" {
|
||||
if strings.ToLower(logLevel) == traceLog || strings.ToLower(logLevel) == "debug" {
|
||||
logWithCaller("DEBUG", msg, args...)
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func Debug(msg string, args ...interface{}) {
|
||||
func Trace(msg string, args ...interface{}) {
|
||||
log.SetOutput(getStd(util.GetStringEnv("GOMA_ACCESS_LOG", "/dev/stdout")))
|
||||
logLevel := util.GetStringEnv("GOMA_LOG_LEVEL", "")
|
||||
if strings.ToLower(logLevel) == "trace" {
|
||||
if strings.ToLower(logLevel) == traceLog {
|
||||
logWithCaller("DEBUG", msg, args...)
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func logWithCaller(level, msg string, args ...interface{}) {
|
||||
// Log message with caller information if GOMA_LOG_LEVEL is trace
|
||||
logLevel := util.GetStringEnv("GOMA_LOG_LEVEL", "")
|
||||
if strings.ToLower(logLevel) != "off" {
|
||||
if strings.ToLower(logLevel) == "trace" {
|
||||
if strings.ToLower(logLevel) == traceLog {
|
||||
log.Printf("%s: %s (File: %s, Line: %d)\n", level, formattedMessage, file, line)
|
||||
} else {
|
||||
log.Printf("%s: %s\n", level, formattedMessage)
|
||||
|
||||
20
pkg/logger/var.go
Normal file
20
pkg/logger/var.go
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2024 Jonas Kaninda
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package logger
|
||||
|
||||
const traceLog = "trace"
|
||||
Reference in New Issue
Block a user