https://github.com/davewhit3/log
Golang logger
https://github.com/davewhit3/log
go golang log logger logging
Last synced: 12 months ago
JSON representation
Golang logger
- Host: GitHub
- URL: https://github.com/davewhit3/log
- Owner: davewhit3
- Created: 2021-04-29T07:06:04.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-01T13:14:03.000Z (almost 5 years ago)
- Last Synced: 2025-06-11T11:42:11.859Z (about 1 year ago)
- Topics: go, golang, log, logger, logging
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# logger #
Logger is a simple cross platform Go logging library for Windows, Linux, FreeBSD, and
macOS, it can log to the Windows event log, Linux/macOS syslog, and an io.Writer.
## Usage ##
Set up the default logger to log the system log (event log or syslog):
```go
package main
import (
"github.com/bialas1993/log"
)
func main() {
log.Debug("debug")
log.With(log.LogFields{
"asd": "bsd",
"lorem": "ipsum",
"bang": 10,
"struct": struct {
A string
}{"aaaaaa"},
}).Info("info")
}
```
## Custom Format ##
| Code | Example |
|-----------------------------------|----------------------------------------------------------|
| `log.SetFlags(log.Ldate)` | ERROR: 2018/11/11 Error running Foobar: message |
| `log.SetFlags(log.Ltime)` | ERROR: 09:42:45 Error running Foobar: message |
| `log.SetFlags(log.Lmicroseconds)` | ERROR: 09:42:50.776015 Error running Foobar: message |
| `log.SetFlags(log.Llongfile)` | ERROR: /src/main.go:31: Error running Foobar: message |
| `log.SetFlags(log.Lshortfile)` | ERROR: main.go:31: Error running Foobar: message |
| `log.SetFlags(log.LUTC)` | ERROR: Error running Foobar: message |
| `log.SetFlags(log.LstdFlags)` | ERROR: 2018/11/11 09:43:12 Error running Foobar: message |
More info: https://golang.org/pkg/log/#pkg-constants