Skip to content

ric-v/glog

Repository files navigation

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

Benchmark Iterations Time Size Allocation
BenchmarkJSONGlog 266092 3853 ns/op 2185 B/op 25 allocs/op
BenchmarkUnstructureGlog_log 412342 3054 ns/o 984 B/op 13 allocs/op

Examples

visit examples here

Code.Share.Prosper