ric-v / glog

Concurrent Thread-Safe Simple Logger for Golang

Home Page:https://pkg.go.dev/github.com/ric-v/glog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Concurrent Thread-Safe Simple Logger for Golang

https://pkg.go.dev/github.com/ric-v/glog

License:MIT License


Languages

Language:Go 100.0%