go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/logutil/error.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package logutil 9 10 import ( 11 "fmt" 12 "log" 13 ) 14 15 // Error prints an error message with a given format and arguments. 16 func Error(l *log.Logger, err error) { 17 if l == nil { 18 return 19 } 20 if l.Flags()&Lerror == 0 { 21 return 22 } 23 l.Output(SDKStackDepth(), fmt.Sprintf("ERROR: %+v", err)) 24 } 25 26 // Errorf prints an error message with a given format and arguments. 27 func Errorf(l *log.Logger, format string, args ...interface{}) { 28 if l == nil { 29 return 30 } 31 if l.Flags()&Lerror == 0 { 32 return 33 } 34 l.Output(2, fmt.Sprintf("ERROR: "+format, args...)) 35 }