All Projects → philchia → Gol

philchia / Gol

Licence: mit
gol is a high performance async log kit for golang

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Gol

Tlog
Terminal I/O logger
Stars: ✭ 170 (+2.41%)
Mutual labels:  elasticsearch, log
Stripe
Typed .NET clients for stripe.com REST APIs
Stars: ✭ 193 (+16.27%)
Mutual labels:  async, high-performance
Exceptionless
Exceptionless server and jobs
Stars: ✭ 2,107 (+1169.28%)
Mutual labels:  elasticsearch, log
Golog
A high-performant Logging Foundation for Go Applications. X3 faster than the rest leveled loggers.
Stars: ✭ 208 (+25.3%)
Mutual labels:  log, high-performance
Uvloop
Ultra fast asyncio event loop.
Stars: ✭ 8,246 (+4867.47%)
Mutual labels:  async, high-performance
clue
a extremely high performance log library for android. 高性能的Android日志库
Stars: ✭ 27 (-83.73%)
Mutual labels:  log, high-performance
Activej
ActiveJ is an alternative Java platform built from the ground up. ActiveJ redefines web, high load, and cloud programming in Java, featuring ultimate performance and scalability!
Stars: ✭ 183 (+10.24%)
Mutual labels:  async, high-performance
Dapeng Soa
A lightweight, high performance micro-service framework
Stars: ✭ 101 (-39.16%)
Mutual labels:  async, high-performance
May
rust stackful coroutine library
Stars: ✭ 909 (+447.59%)
Mutual labels:  async, high-performance
Tank
A very high performance distributed log service
Stars: ✭ 927 (+458.43%)
Mutual labels:  log, high-performance
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-69.28%)
Mutual labels:  elasticsearch, log
Easylogger
An ultra-lightweight(ROM<1.6K, RAM<0.3k), high-performance C/C++ log library. | 一款超轻量级(ROM<1.6K, RAM<0.3k)、高性能的 C/C++ 日志库
Stars: ✭ 1,968 (+1085.54%)
Mutual labels:  log, high-performance
Metasync
Asynchronous Programming Library for JavaScript & Node.js
Stars: ✭ 164 (-1.2%)
Mutual labels:  async
Mimirsbrunn
Geocoding and reverse-geocoding (with OSM data)
Stars: ✭ 165 (-0.6%)
Mutual labels:  elasticsearch
Adventurelookup
Adventure Lookup Main Repository
Stars: ✭ 164 (-1.2%)
Mutual labels:  elasticsearch
Spring Boot Leaning
Spring Boot 2.X 最全课程代码
Stars: ✭ 2,008 (+1109.64%)
Mutual labels:  elasticsearch
Sense Chrome
Sense (elasticsearch) for chrome extension
Stars: ✭ 166 (+0%)
Mutual labels:  elasticsearch
Dockerfile
some personally made dockerfile
Stars: ✭ 2,021 (+1117.47%)
Mutual labels:  elasticsearch
Haproxy
HAProxy Load Balancer's development branch (mirror of git.haproxy.org)
Stars: ✭ 2,463 (+1383.73%)
Mutual labels:  high-performance
Falcon
A high-performance web server for Ruby, supporting HTTP/1, HTTP/2 and TLS.
Stars: ✭ 2,058 (+1139.76%)
Mutual labels:  async

gol: a high performance async log kit for golang

Golang Build Status Coverage Status codebeat badge Go Report Card GoDoc license

gol is a high performance async log infrastructure for golang, which include several useful log backend adapters, include file/file rotate/stmp/slack/elasticsearch etc...

Introduce

Level

gol support various log levels, you can set the logger's level to disable some lower level output

const (
    ALL LogLevel = iota
    DEBUG
    INFO
    WARN
    ERROR
    CRITICAL
)

Built in adapters

gol has several built in adapters

  • Console adapter support write log to stderr, and this is the default adapter
  • File adapter support write log to file
  • File rotate adapter support write log to rotate files
  • Smtp adapter support write log to email
  • Slack adapter support write log to given slack channel
  • ES adapter support write log to elastic search (under development)

Customize backend adapters

You can create any backend adapter which implement the Adapter interface.

Actually Adapter is a alias of io.Writer

type Adapter interface {
    io.WriteCloser
}

Color

gol also include a colorful output

Colorful output

Usage

Log to console

import (
    "github.com/philchia/gol"
    "runtime"
)

defer gol.Flush()
gol.Debug("Hello, gol!!!")
gol.Criticalf("Hello from %s", runtime.GOOS)

Not log to console

import (
    "github.com/philchia/gol"
    "runtime"
)
gol.RemoveAdapter(gol.CONSOLELOGGER)

Log to file

import (
    "github.com/philchia/gol"
    "runtime"
)

defer gol.Flush()
gol.AddLogAdapter("file", file.NewAdapter("/var/log/tmp.log"))
gol.Debug("Hello, gol!!!")
gol.Criticalf("Hello from %s", runtime.GOOS)

Rotate log to file

import (
    "github.com/philchia/gol"
    "runtime"
)

defer gol.Flush()
gol.AddLogAdapter("rotate file", rotatefile.NewAdapter("./temp.log", 6, rotatefile.KB*1))
gol.Debug("Hello, gol!!!")
gol.Criticalf("Hello from %s", runtime.GOOS)

Set level

import (
    "github.com/philchia/gol"
    "runtime"
)

defer gol.Flush()
gol.SetLevel(gol.ERROR)
gol.Debug("Hello, gol!!!") // this will not print
gol.Criticalf("Hello from %s", runtime.GOOS)

Set options

import (
    "github.com/philchia/gol"
    "runtime"
)

defer gol.Flush()
gol.SetOption(gol.Llongfile | gol.Ldate | gol.Ltime | gol.Lmicroseconds)
gol.Debug("Hello, gol!!!")
gol.Criticalf("Hello from %s", runtime.GOOS)

Add adapters

You can implement you own custom adapters which implement the Adapter interface.

import (
    "github.com/philchia/gol"
    "runtime"
)

defer gol.Flush()
gol.SetOption(gol.Llongfile | gol.Ldate | gol.Ltime | gol.Lmicroseconds)
gol.AddLogAdapter("anonymous", a)
gol.Debug("Hello, gol!!!")
gol.Criticalf("Hello from %s", runtime.GOOS)

Installation

$go get github.com/philchia/gol

or you can use go get -u to update the package

Documentation

For docs, see Documentation or run:

$godoc github.com/philchia/gol

Benchmark

gol include a benchmark against the builtin log package, run $go test ./... -bench . -benchmem in your terminal to run the bench

Benchmark

Features

  • [X] Log level support
  • [X] Customizable log option support
  • [X] Async write
  • [X] Colorful output
  • [X] Flush buffered log
  • [X] Toggle console adapter
  • [X] Logrotate
  • [X] Mail adapter
  • [X] Slack adapter
  • [X] Level support for single adapter
  • [ ] Elastic Search adapter for ELK stack
  • [ ] 100% coverage
  • [ ] Customizable msg buffer size

License

gol code is published under the MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].