All Projects → szuecs → Gin Glog

szuecs / Gin Glog

Licence: mit
Gin middleware to use glog

Programming Languages

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

Projects that are alternatives of or similar to Gin Glog

Gzip
💾 Golang gzip middleware for Gin and net/http | Golang gzip中间件,支持Gin和net/http,开箱即用同时可定制
Stars: ✭ 113 (+113.21%)
Mutual labels:  middleware, gin
Chromelogger Python
Python library for logging variables to Google Chrome console
Stars: ✭ 232 (+337.74%)
Mutual labels:  middleware, logging
Gin Swagger
gin middleware to automatically generate RESTful API documentation with Swagger 2.0.
Stars: ✭ 2,001 (+3675.47%)
Mutual labels:  middleware, gin
Gin Cors
Cross Origin Resource Sharing middleware for gin-gonic
Stars: ✭ 107 (+101.89%)
Mutual labels:  middleware, gin
Concurrency Logger
Log HTTP requests/responses separately, visualize their concurrency and report logs/errors in context of a request.
Stars: ✭ 400 (+654.72%)
Mutual labels:  middleware, logging
Gin
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
Stars: ✭ 53,971 (+101732.08%)
Mutual labels:  middleware, gin
Ginrpc
gin auto binding,grpc, and annotated route,gin 注解路由, grpc,自动参数绑定工具
Stars: ✭ 157 (+196.23%)
Mutual labels:  middleware, gin
Go Http Metrics
Go modular http middleware to measure HTTP requests independent of metrics backend (with Prometheus and OpenCensus as backend implementations) and http framework/library
Stars: ✭ 128 (+141.51%)
Mutual labels:  middleware, gin
Laravel Logger
An out the box activity logger for your Laravel or Lumen application. Laravel logger is an activity event logger for your laravel application. It comes out the box with ready to use with dashboard to view your activity. Laravel logger can be added as a middleware or called through a trait. This package is easily configurable and customizable. Supports Laravel 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, and 7+
Stars: ✭ 366 (+590.57%)
Mutual labels:  middleware, logging
Go Grpc Middleware
Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.
Stars: ✭ 4,170 (+7767.92%)
Mutual labels:  middleware, logging
Speedbump
A Redis-backed rate limiter in Go
Stars: ✭ 107 (+101.89%)
Mutual labels:  middleware, gin
Logger
HTTP middleware for Go that logs web requests to an io.Writer.
Stars: ✭ 24 (-54.72%)
Mutual labels:  middleware, logging
Diary
📑 Zero-dependency, fast logging library for both Node and Browser.
Stars: ✭ 79 (+49.06%)
Mutual labels:  middleware, logging
Gin Web
由gin + gorm + jwt + casbin组合实现的RBAC权限管理脚手架Golang版, 搭建完成即可快速、高效投入业务开发
Stars: ✭ 107 (+101.89%)
Mutual labels:  middleware, gin
Logrus
Hooks for logrus logging
Stars: ✭ 110 (+107.55%)
Mutual labels:  gin, logging
Home
Project Glimpse: Node Edition - Spend less time debugging and more time developing.
Stars: ✭ 260 (+390.57%)
Mutual labels:  middleware, logging
Gear
A lightweight, composable and high performance web service framework for Go.
Stars: ✭ 544 (+926.42%)
Mutual labels:  middleware, logging
Gin Stats
Gin's middleware for request stats
Stars: ✭ 24 (-54.72%)
Mutual labels:  middleware, gin
Dawn
🌅 Dawn is a lightweight task management and build tool for front-end and nodejs.
Stars: ✭ 1,057 (+1894.34%)
Mutual labels:  middleware
Raspberrypi tempmon
Raspberry pi CPU temperature monitor with many functions such as logging, GPIO output, graphing, email, alarm, notifications and stress testing. Python 3.
Stars: ✭ 52 (-1.89%)
Mutual labels:  logging

Gin-Glog

Gin middleware for Logging with glog. It is meant as drop in replacement for the default logger used in Gin.

Build Status Coverage Status Go Report Card GoDoc

Project Context and Features

When it comes to choosing a Go framework, there's a lot of confusion about what to use. The scene is very fragmented, and detailed comparisons of different frameworks are still somewhat rare. Meantime, how to handle dependencies and structure projects are big topics in the Go community. We've liked using Gin for its speed, accessibility, and usefulness in developing microservice architectures. In creating Gin-Glog, we wanted to take fuller advantage of Gin's capabilities and help other devs do likewise.

Gin-Glog replaces the default logger of Gin to use Glog.

How Glog is different compared to other loggers

Glog is an efficient pure Go implementation of leveled logs. If you use Glog, you do not use blocking calls for writing logs. A goroutine in the background will flush queued loglines into appropriate logfiles. It provides logrotation, maintains symlinks to current files and creates flags to your command line interface.

Requirements

Gin-Glog uses the following Go packages as dependencies:

  • github.com/gin-gonic/gin
  • github.com/golang/glog

Installation

Assuming you've installed Go and Gin, run this:

go get github.com/szuecs/gin-glog

Usage

Example

Start your webapp to log to STDERR and /tmp:

% ./webapp -log_dir="/tmp" -alsologtostderr -v=2
package main

import (
    "flag"
    "time"

    "github.com/golang/glog"
    "github.com/szuecs/gin-glog"
    "github.com/gin-gonic/gin"
)

func main() {
    flag.Parse()
    router := gin.New()
    router.Use(ginglog.Logger(3 * time.Second))
    //..
    router.Use(gin.Recovery())

    glog.Warning("warning")
    glog.Error("err")
    glog.Info("info")
    glog.V(2).Infoln("This line will be printed if you use -v=N with N >= 2.")

    router.Run(":8080")
}

STDERR output of the example above. Lines with prefix "[Gin-Debug]" are hardcoded output of Gin and will not appear in your logfile:

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

W0306 16:37:12.836001     367 main.go:18] warning
E0306 16:37:12.836335     367 main.go:19] err
I0306 16:37:12.836402     367 main.go:20] info
I0306 16:26:33.901278   32538 main.go:19] This line will be printed if you use -v=N with N >= 2.
[GIN-debug] Listening and serving HTTP on :8080

Synopsis

Glog will add the following flags to your binary:

-alsologtostderr
      log to standard error as well as files
-log_backtrace_at value
      when logging hits line file:N, emit a stack trace (default :0)
-log_dir string
      If non-empty, write log files in this directory
-logtostderr
      log to standard error instead of files
-stderrthreshold value
      logs at or above this threshold go to stderr
-v value
      log level for V logs
-vmodule value
      comma-separated list of pattern=N settings for file-filtered logging

Contributing/TODO

We welcome contributions from the community; just submit a pull request. To help you get started, here are some items that we'd love help with:

  • Remove hardcoded logs in Gin
  • the code base

Please use github issues as starting point for contributions, new ideas or bugreports.

Contact

Contributors

Thanks to:

  • <your name>

License

See LICENSE file.

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].