-
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
Showing
1 changed file
with
31 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/charmbracelet/log" | ||
"github.com/lvlcn-t/loggerhead/logger" | ||
) | ||
|
||
func main() { | ||
// Setups a custom handler for the logger. | ||
clog := log.New(os.Stdout) | ||
clog.SetLevel(log.DebugLevel) | ||
|
||
// Create a new logger with the custom handler. | ||
l := logger.NewLogger(clog) | ||
|
||
// Log some messages. | ||
l.Debug("I'm not sure what's happening.") | ||
l.Info("Hello, world in pretty colors!") | ||
l.Warn("I'm warning you!") | ||
l.Error("I'm sorry. I'm afraid you did something wrong.") | ||
func() { | ||
defer func() { | ||
if r := recover(); r != nil { | ||
l.Fatal("I'm dying!") | ||
} | ||
}() | ||
l.Panic("I'm panicking!") | ||
}() | ||
} |