mirror of
https://github.com/taigrr/log-socket
synced 2025-01-18 04:53:14 -08:00
fixes fileinfo reflection issue
This commit is contained in:
parent
45cad34fdc
commit
b3ceb12277
@ -7,13 +7,17 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (l Logger) SetInfoDepth(depth int) {
|
||||||
|
l.FileInfoDepth = depth
|
||||||
|
}
|
||||||
|
|
||||||
// Trace prints out logs on trace level
|
// Trace prints out logs on trace level
|
||||||
func (_ Logger) Trace(args ...interface{}) {
|
func (l Logger) Trace(args ...interface{}) {
|
||||||
output := fmt.Sprint(args...)
|
output := fmt.Sprint(args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "TRACE",
|
Level: "TRACE",
|
||||||
level: LTrace,
|
level: LTrace,
|
||||||
}
|
}
|
||||||
@ -21,12 +25,12 @@ func (_ Logger) Trace(args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Formatted print for Trace
|
// Formatted print for Trace
|
||||||
func (_ Logger) Tracef(format string, args ...interface{}) {
|
func (l Logger) Tracef(format string, args ...interface{}) {
|
||||||
output := fmt.Sprintf(format, args...)
|
output := fmt.Sprintf(format, args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "TRACE",
|
Level: "TRACE",
|
||||||
level: LTrace,
|
level: LTrace,
|
||||||
}
|
}
|
||||||
@ -34,12 +38,12 @@ func (_ Logger) Tracef(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debug prints out logs on debug level
|
// Debug prints out logs on debug level
|
||||||
func (_ Logger) Debug(args ...interface{}) {
|
func (l Logger) Debug(args ...interface{}) {
|
||||||
output := fmt.Sprint(args...)
|
output := fmt.Sprint(args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "DEBUG",
|
Level: "DEBUG",
|
||||||
level: LDebug,
|
level: LDebug,
|
||||||
}
|
}
|
||||||
@ -47,12 +51,12 @@ func (_ Logger) Debug(args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Formatted print for Debug
|
// Formatted print for Debug
|
||||||
func (_ Logger) Debugf(format string, args ...interface{}) {
|
func (l Logger) Debugf(format string, args ...interface{}) {
|
||||||
output := fmt.Sprintf(format, args...)
|
output := fmt.Sprintf(format, args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "DEBUG",
|
Level: "DEBUG",
|
||||||
level: LDebug,
|
level: LDebug,
|
||||||
}
|
}
|
||||||
@ -60,12 +64,12 @@ func (_ Logger) Debugf(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Info prints out logs on info level
|
// Info prints out logs on info level
|
||||||
func (_ Logger) Info(args ...interface{}) {
|
func (l Logger) Info(args ...interface{}) {
|
||||||
output := fmt.Sprint(args...)
|
output := fmt.Sprint(args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "INFO",
|
Level: "INFO",
|
||||||
level: LInfo,
|
level: LInfo,
|
||||||
}
|
}
|
||||||
@ -73,12 +77,12 @@ func (_ Logger) Info(args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Formatted print for Info
|
// Formatted print for Info
|
||||||
func (_ Logger) Infof(format string, args ...interface{}) {
|
func (l Logger) Infof(format string, args ...interface{}) {
|
||||||
output := fmt.Sprintf(format, args...)
|
output := fmt.Sprintf(format, args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "INFO",
|
Level: "INFO",
|
||||||
level: LInfo,
|
level: LInfo,
|
||||||
}
|
}
|
||||||
@ -86,12 +90,12 @@ func (_ Logger) Infof(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Info prints out logs on info level
|
// Info prints out logs on info level
|
||||||
func (_ Logger) Notice(args ...interface{}) {
|
func (l Logger) Notice(args ...interface{}) {
|
||||||
output := fmt.Sprint(args...)
|
output := fmt.Sprint(args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "NOTICE",
|
Level: "NOTICE",
|
||||||
level: LNotice,
|
level: LNotice,
|
||||||
}
|
}
|
||||||
@ -99,12 +103,12 @@ func (_ Logger) Notice(args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Formatted print for Info
|
// Formatted print for Info
|
||||||
func (_ Logger) Noticef(format string, args ...interface{}) {
|
func (l Logger) Noticef(format string, args ...interface{}) {
|
||||||
output := fmt.Sprintf(format, args...)
|
output := fmt.Sprintf(format, args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "NOTICE",
|
Level: "NOTICE",
|
||||||
level: LNotice,
|
level: LNotice,
|
||||||
}
|
}
|
||||||
@ -112,12 +116,12 @@ func (_ Logger) Noticef(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Warn prints out logs on warn level
|
// Warn prints out logs on warn level
|
||||||
func (_ Logger) Warn(args ...interface{}) {
|
func (l Logger) Warn(args ...interface{}) {
|
||||||
output := fmt.Sprint(args...)
|
output := fmt.Sprint(args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "WARN",
|
Level: "WARN",
|
||||||
level: LWarn,
|
level: LWarn,
|
||||||
}
|
}
|
||||||
@ -125,12 +129,12 @@ func (_ Logger) Warn(args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Formatted print for Warn
|
// Formatted print for Warn
|
||||||
func (_ Logger) Warnf(format string, args ...interface{}) {
|
func (l Logger) Warnf(format string, args ...interface{}) {
|
||||||
output := fmt.Sprintf(format, args...)
|
output := fmt.Sprintf(format, args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "WARN",
|
Level: "WARN",
|
||||||
level: LWarn,
|
level: LWarn,
|
||||||
}
|
}
|
||||||
@ -138,12 +142,12 @@ func (_ Logger) Warnf(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Error prints out logs on error level
|
// Error prints out logs on error level
|
||||||
func (_ Logger) Error(args ...interface{}) {
|
func (l Logger) Error(args ...interface{}) {
|
||||||
output := fmt.Sprint(args...)
|
output := fmt.Sprint(args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "ERROR",
|
Level: "ERROR",
|
||||||
level: LError,
|
level: LError,
|
||||||
}
|
}
|
||||||
@ -151,12 +155,12 @@ func (_ Logger) Error(args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Formatted print for error
|
// Formatted print for error
|
||||||
func (_ Logger) Errorf(format string, args ...interface{}) {
|
func (l Logger) Errorf(format string, args ...interface{}) {
|
||||||
output := fmt.Sprintf(format, args...)
|
output := fmt.Sprintf(format, args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "ERROR",
|
Level: "ERROR",
|
||||||
level: LError,
|
level: LError,
|
||||||
}
|
}
|
||||||
@ -164,12 +168,12 @@ func (_ Logger) Errorf(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Panic prints out logs on panic level
|
// Panic prints out logs on panic level
|
||||||
func (_ Logger) Panic(args ...interface{}) {
|
func (l Logger) Panic(args ...interface{}) {
|
||||||
output := fmt.Sprint(args...)
|
output := fmt.Sprint(args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "PANIC",
|
Level: "PANIC",
|
||||||
level: LPanic,
|
level: LPanic,
|
||||||
}
|
}
|
||||||
@ -187,12 +191,12 @@ func (_ Logger) Panic(args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Formatted print for panic
|
// Formatted print for panic
|
||||||
func (_ Logger) Panicf(format string, args ...interface{}) {
|
func (l Logger) Panicf(format string, args ...interface{}) {
|
||||||
output := fmt.Sprintf(format, args...)
|
output := fmt.Sprintf(format, args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "PANIC",
|
Level: "PANIC",
|
||||||
level: LPanic,
|
level: LPanic,
|
||||||
}
|
}
|
||||||
@ -210,12 +214,12 @@ func (_ Logger) Panicf(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fatal prints out logs on fatal level
|
// Fatal prints out logs on fatal level
|
||||||
func (_ Logger) Fatal(args ...interface{}) {
|
func (l Logger) Fatal(args ...interface{}) {
|
||||||
output := fmt.Sprint(args...)
|
output := fmt.Sprint(args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "FATAL",
|
Level: "FATAL",
|
||||||
level: LFatal,
|
level: LFatal,
|
||||||
}
|
}
|
||||||
@ -225,12 +229,12 @@ func (_ Logger) Fatal(args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Formatted print for fatal
|
// Formatted print for fatal
|
||||||
func (_ Logger) Fatalf(format string, args ...interface{}) {
|
func (l Logger) Fatalf(format string, args ...interface{}) {
|
||||||
output := fmt.Sprintf(format, args...)
|
output := fmt.Sprintf(format, args...)
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
Output: output,
|
Output: output,
|
||||||
File: fileInfo(3),
|
File: fileInfo(l.FileInfoDepth),
|
||||||
Level: "FATAL",
|
Level: "FATAL",
|
||||||
level: LFatal,
|
level: LFatal,
|
||||||
}
|
}
|
||||||
|
@ -31,4 +31,5 @@ type Entry struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Logger struct {
|
type Logger struct {
|
||||||
|
FileInfoDepth int
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user