-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
longhaoteng
committed
Apr 24, 2023
1 parent
ae0399b
commit ffa2589
Showing
4 changed files
with
46 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,7 @@ func (t *Test) Run() { | |
func (t *Test) execute() { | ||
log.Info("coon test") | ||
} | ||
|
||
func init() { | ||
cron.AddJobs(&Test{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package logger | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"runtime" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
type defaultHook struct{} | ||
|
||
func (d defaultHook) Levels() []logrus.Level { | ||
return logrus.AllLevels | ||
} | ||
|
||
func (d defaultHook) Fire(e *logrus.Entry) error { | ||
pos := "unknown" | ||
_, file, line, ok := runtime.Caller(6) | ||
if ok { | ||
pos = fmt.Sprintf("%v:%v", filepath.Base(file), line) | ||
} | ||
e.Data["pos"] = pos | ||
|
||
return nil | ||
} | ||
|
||
func init() { | ||
AddHook(&defaultHook{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters