feat: ✨ use log.textformatter
This commit is contained in:
parent
76e800c9d4
commit
b2c43a5f3d
19
main.go
19
main.go
@ -55,14 +55,14 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetFormatter(new(formatter))
|
log.SetFormatter(&log.TextFormatter{
|
||||||
|
DisableTimestamp: true,
|
||||||
|
})
|
||||||
|
|
||||||
switch args.Level {
|
switch args.Level {
|
||||||
case "debug":
|
case "debug":
|
||||||
log.SetFormatter(textFormatter)
|
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
case "trace":
|
case "trace":
|
||||||
log.SetFormatter(textFormatter)
|
|
||||||
log.SetLevel(log.TraceLevel)
|
log.SetLevel(log.TraceLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,16 +70,3 @@ func main() {
|
|||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// default formatter that writes logs without including timestamp
|
|
||||||
// or level information.
|
|
||||||
type formatter struct{}
|
|
||||||
|
|
||||||
func (*formatter) Format(entry *log.Entry) ([]byte, error) {
|
|
||||||
return []byte(entry.Message), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// text formatter that writes logs with level information
|
|
||||||
var textFormatter = &log.TextFormatter{
|
|
||||||
DisableTimestamp: true,
|
|
||||||
}
|
|
||||||
|
@ -50,7 +50,7 @@ func SetBasicAuth(username, password string) func(repo *git.Repository) error {
|
|||||||
|
|
||||||
func FetchTags() func(repo *git.Repository) error {
|
func FetchTags() func(repo *git.Repository) error {
|
||||||
return func(repo *git.Repository) error {
|
return func(repo *git.Repository) error {
|
||||||
log.Info("Fetching latest git tags")
|
log.Info("Fetching git tags")
|
||||||
|
|
||||||
err := repo.Fetch(&git.FetchOptions{Tags: git.AllTags})
|
err := repo.Fetch(&git.FetchOptions{Tags: git.AllTags})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user