https://github.com/pteich/logger
Simple wrapper around zerolog b/c I permanently need something like this and forget where I used it before.
https://github.com/pteich/logger
golang logging
Last synced: 27 days ago
JSON representation
Simple wrapper around zerolog b/c I permanently need something like this and forget where I used it before.
- Host: GitHub
- URL: https://github.com/pteich/logger
- Owner: pteich
- License: mit
- Created: 2020-01-29T19:09:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-31T21:56:29.000Z (over 2 years ago)
- Last Synced: 2025-01-15T15:19:52.028Z (over 1 year ago)
- Topics: golang, logging
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# logger
--
import "github.com/pteich/logger"
## Usage
#### type Logger
```go
type Logger struct {
zerolog.Logger
}
```
Logger represents a logger that embeds zerolog
#### func New
```go
func New(opts ...Option) *Logger
```
New returns a new logger with specific options (zero to x)
#### func NewFromZerolog
```go
func NewFromZerolog(logger zerolog.Logger) *Logger
```
NewFromZerolog returns a new logger from an existing zerolog instance
#### func (*Logger) Log
```go
func (log *Logger) Log(v ...interface{}) error
```
Log implements a common log interface
#### type Option
```go
type Option func(c *config)
```
Options is an config setting function
#### func WithLogConsole
```go
func WithLogConsole() Option
```
WithLogConsole enabled human readable logging to console
#### func WithLogLevel
```go
func WithLogLevel(logLevel string) Option
```
WithLogLevel sets a specific loglevel given as string (e.g. debug)
#### func WithNanoSeconds
```go
func WithNanoSeconds() Option
```
WithNanoSeconds logs timestamp with nanos if millis are not enough
#### func WithServiceName
```go
func WithServiceName(serviceName string) Option
```
WithServiceName sets a service name as log field