Skip to content
This repository was archived by the owner on Nov 21, 2023. It is now read-only.

Commit 677f0f1

Browse files
authoredMar 3, 2022
Merge pull request #21 from goinsane/develop
v1.2.3
2 parents 2421d19 + be6817a commit 677f0f1

File tree

2 files changed

+19
-43
lines changed

2 files changed

+19
-43
lines changed
 

‎logger.go

+13-27
Original file line numberDiff line numberDiff line change
@@ -405,41 +405,36 @@ func (l *Logger) WithFieldMap(fieldMap map[string]interface{}) *Logger {
405405
return l.WithFields(fields...)
406406
}
407407

408-
// ErfError creates a new *erf.Erf by given arguments. It logs to the ERROR severity logs and returns the *erf.Erf.
409-
func (l *Logger) ErfError(text string) *erf.Erf {
410-
return l.erfError(SeverityError, text)
408+
// ErfError creates a new *erf.Erf by the given argument. It logs to the ERROR severity logs and returns the *erf.Erf.
409+
func (l *Logger) ErfError(arg interface{}) *erf.Erf {
410+
return l.erfError(SeverityError, arg)
411411
}
412412

413413
// ErfErrorf creates a new *erf.Erf by given arguments. It logs to the ERROR severity logs and returns the result to call Attach method of *erf.Erf.
414414
func (l *Logger) ErfErrorf(format string, args ...interface{}) *loggerErfResult {
415415
return l.erfErrorf(SeverityError, format, args...)
416416
}
417417

418-
// ErfErrorWrap creates a new *erf.Erf by given error e. It logs to the ERROR severity logs and returns the *erf.Erf.
419-
func (l *Logger) ErfErrorWrap(e error) *erf.Erf {
420-
return l.erfErrorWrap(SeverityError, e)
421-
}
422-
423-
// ErfWarning creates a new *erf.Erf by given arguments. It logs to the WARNING severity logs and returns the *erf.Erf.
424-
func (l *Logger) ErfWarning(text string) *erf.Erf {
425-
return l.erfError(SeverityWarning, text)
418+
// ErfWarning creates a new *erf.Erf by the given argument. It logs to the WARNING severity logs and returns the *erf.Erf.
419+
func (l *Logger) ErfWarning(arg interface{}) *erf.Erf {
420+
return l.erfError(SeverityWarning, arg)
426421
}
427422

428423
// ErfWarningf creates a new *erf.Erf by given arguments. It logs to the WARNING severity logs and returns the result to call Attach method of *erf.Erf.
429424
func (l *Logger) ErfWarningf(format string, args ...interface{}) *loggerErfResult {
430425
return l.erfErrorf(SeverityWarning, format, args...)
431426
}
432427

433-
// ErfWarningWrap creates a new *erf.Erf by given error e. It logs to the WARNING severity logs and returns the *erf.Erf.
434-
func (l *Logger) ErfWarningWrap(e error) *erf.Erf {
435-
return l.erfErrorWrap(SeverityWarning, e)
436-
}
437-
438-
func (l *Logger) erfError(severity Severity, text string) *erf.Erf {
428+
func (l *Logger) erfError(severity Severity, arg interface{}) *erf.Erf {
439429
result := &loggerErfResult{
440430
l: l.Duplicate(),
441431
s: severity,
442-
e: erf.New(text).CopyByTop(2),
432+
e: nil,
433+
}
434+
if e, ok := arg.(error); ok {
435+
result.e = erf.Wrap(e).(*erf.Erf).CopyByTop(2)
436+
} else {
437+
result.e = erf.New(fmt.Sprint(arg)).CopyByTop(2)
443438
}
444439
return result.Attach()
445440
}
@@ -453,15 +448,6 @@ func (l *Logger) erfErrorf(severity Severity, format string, args ...interface{}
453448
return result
454449
}
455450

456-
func (l *Logger) erfErrorWrap(severity Severity, e error) *erf.Erf {
457-
result := &loggerErfResult{
458-
l: l.Duplicate(),
459-
s: severity,
460-
e: erf.Wrap(e).(*erf.Erf).CopyByTop(2),
461-
}
462-
return result.Attach()
463-
}
464-
465451
type loggerErfResult struct {
466452
l *Logger
467453
s Severity

‎xlog.go

+6-16
Original file line numberDiff line numberDiff line change
@@ -209,36 +209,26 @@ func SetOutputFlags(flags Flag) *TextOutput {
209209
return defaultOutput.SetFlags(flags)
210210
}
211211

212-
// ErfError creates a new *erf.Erf by given arguments. It logs to the ERROR severity logs to the default Logger and returns the *erf.Erf.
213-
func ErfError(text string) *erf.Erf {
214-
return defaultLogger.erfError(SeverityError, text)
212+
// ErfError creates a new *erf.Erf by the given argument. It logs to the ERROR severity logs to the default Logger and returns the *erf.Erf.
213+
func ErfError(arg interface{}) *erf.Erf {
214+
return defaultLogger.erfError(SeverityError, arg)
215215
}
216216

217217
// ErfErrorf creates a new *erf.Erf by given arguments. It logs to the ERROR severity logs to the default Logger and the result to call Attach method of *erf.Erf.
218218
func ErfErrorf(format string, args ...interface{}) *loggerErfResult {
219219
return defaultLogger.erfErrorf(SeverityError, format, args...)
220220
}
221221

222-
// ErfErrorWrap creates a new *erf.Erf by given error e. It logs to the ERROR severity logs to the default Logger and returns the *erf.Erf.
223-
func ErfErrorWrap(e error) *erf.Erf {
224-
return defaultLogger.erfErrorWrap(SeverityError, e)
225-
}
226-
227-
// ErfWarning creates a new *erf.Erf by given arguments. It logs to the WARNING severity logs to the default Logger and returns the *erf.Erf.
228-
func ErfWarning(text string) *erf.Erf {
229-
return defaultLogger.erfError(SeverityWarning, text)
222+
// ErfWarning creates a new *erf.Erf by the given argument. It logs to the WARNING severity logs to the default Logger and returns the *erf.Erf.
223+
func ErfWarning(arg interface{}) *erf.Erf {
224+
return defaultLogger.erfError(SeverityWarning, arg)
230225
}
231226

232227
// ErfWarningf creates a new *erf.Erf by given arguments. It logs to the WARNING severity logs to the default Logger and returns the result to call Attach method of *erf.Erf.
233228
func ErfWarningf(format string, args ...interface{}) *loggerErfResult {
234229
return defaultLogger.erfErrorf(SeverityWarning, format, args...)
235230
}
236231

237-
// ErfWarningWrap creates a new *erf.Erf by given error e. It logs to the WARNING severity logs to the default Logger and returns the *erf.Erf.
238-
func ErfWarningWrap(e error) *erf.Erf {
239-
return defaultLogger.erfErrorWrap(SeverityWarning, e)
240-
}
241-
242232
// Reset resets the default Logger and the default Output.
243233
func Reset() {
244234
SetOutput(defaultOutput)

0 commit comments

Comments
 (0)