All projects

Libraries

glog

A concurrent, thread-safe logger for Go.

Why it existsLogging from many goroutines shouldn't need hand-rolled locking. glog is safe to call from anywhere and outputs plain text or structured JSON with one line of setup.

Simple interfaces for fast, safe logging from many goroutines, in plain text or structured JSON.

Stars
1
Forks
0
Last push
Updated 5 years ago

Languages

Go100.0%
README.md
glog screenshot: Glugger

Glog

Glog glugs the log files in a concurrent and thread-safe way.

Simple and easy to implement interfaces to log fast and efficiently

Go CodeQL Go Report Card CodeFactor Maintained Quality Gate Status GoDoc


Features

  • Thread-safe logger
  • Log formatting support
  • Logging in unstructured or structured format (JSON)

Usage

go get github.com/ric-v/glog

simple logger to stdout

package main

import "github.com/ric-v/glog"

func main() {
    defer glog.Cleanup()

    // log the message to the default concurrent logger
    glog.Info("Hello World")
}

json logger to file

package main

import "github.com/ric-v/glog"

func main() {
    logger := glog.JSONGlogger("glogger.log")
    defer logger.Cleanup()

    // log the message to custom json logger
    logger.Info("", "Hello", "World")
}

Benchmarks

BenchmarkIterationsTimeSizeAllocation
BenchmarkJSONGlog2660923853 ns/op2185 B/op25 allocs/op
BenchmarkUnstructureGlog_log4123423054 ns/o984 B/op13 allocs/op

Examples

visit examples here

Code.Share.Prosper