https://github.com/furqansoftware/pog
A simple logger for Go with a status indicator
https://github.com/furqansoftware/pog
Last synced: about 2 months ago
JSON representation
A simple logger for Go with a status indicator
- Host: GitHub
- URL: https://github.com/furqansoftware/pog
- Owner: FurqanSoftware
- Created: 2023-05-26T02:13:10.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-10-18T06:33:22.000Z (over 1 year ago)
- Last Synced: 2025-01-30T08:31:28.040Z (4 months ago)
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pog
Pog is a simple logger for Go with a status indicator.
## Usage
``` go
import (
"github.com/FurqanSoftware/pog"
"github.com/fatih/color"
)type pogStatus struct {
icon byte
text string
color *color.Color
throb bool
}func (s pogStatus) Icon() byte { return s.icon }
func (s pogStatus) Text() string { return s.text }
func (s pogStatus) Color() *color.Color { return s.color }
func (s pogStatus) Throb() bool { return s.throb }var (
statusReady = pogStatus{'~', "Ready", color.New(color.FgGreen), true}
statusPrinting = pogStatus{'~', "Printing", color.New(color.FgBlue), false}
statusOffline = pogStatus{'!', "Offline", color.New(color.FgRed), false}
)
`````` go
log.SetPrefix("\033[2K\r")
log.SetFlags(log.Ldate | log.Ltime)pog.InitDefault()
pog.Info("I am ready.")
pog.SetStatus(statusReady)
`````` txt
2023/10/18 11:59:11 [i] I am ready.
[~] Ready
`````` go
pog.Info("Got a print.")
pog.SetStatus(statusPrinting)
pog.Warn("That's a lot of words.")
`````` txt
2023/10/18 11:59:11 [i] I am ready.
2023/10/18 11:59:19 [i] Got a print.
2023/10/18 11:59:19 [w] That's a lot of words.
[~] Printing
`````` go
pog.Error("Lost connection.")
pog.SetStatus(statusOffline)
`````` txt
2023/10/18 11:59:11 [i] I am ready.
2023/10/18 11:59:19 [i] Got a print.
2023/10/18 11:59:19 [w] That's a lot of words.
2023/10/18 11:59:57 [E] Lost connection.
[!] Offline
```