io.Writer implementation using logrus logger

Overview

logrusiowriter

io.Writer implementation using logrus

Travis CI build status GoDoc Coverage Status Mentioned in Awesome Go

Motivation

Many golang libraries use the golang's log package to print their logs. This means that if your application uses logrus to print structured logging, those packages will print a format that is (probably) incompatible with yours, and you may end losing logs in your logs collector because they can't be parsed properly.

Solution

Print the logs written using log.Printf through logrus, by setting log.SetOutput to an io.Writer implementation that uses logrus as output, i.e.:

	log.SetOutput(logrusiowriter.New())

See example_*_test.go files to find testable examples that serve as documentation.

Simple solution

Or... you can simply use the standard APIs that logrus provides, i.e., this does the same as this package:

    log.SetOutput(logrus.WithFields(logrus.Fields{"logger": "stdlib"}).WriterLevel(logrus.InfoLevel))

So, unless you want this to be configurable using an envconfig-filled struct, there's no reason to use this library.

Issues
  • Initial version

    Initial version

    Very first version of this library, see README.md for more details

    opened by colega 0
  • Trim trailing newline characters by default

    Trim trailing newline characters by default

    log.Print, which is the most likely user of this library, always appends a trailing newline characters to what it prints. We don't want it to be printed inside of the message field of logrus, so we trim it.

    opened by colega 0
  • Explain that this library is useless

    Explain that this library is useless

    logrus provides the Writer() and WriterLevel() functions that provide same functionality as this library.

    opened by colega 0
Releases(v1.1.0)
Owner
Cabify
Cabify
A customized GORM logger that implements the appropriate interface and uses Logrus to output logs

CryptoMath GORM Logger A customized GORM logger that implements the appropriate interface and uses Logrus to output logs. Install go get github.com/ma

Crypto Math 0 Nov 6, 2021
Convenient Logger interface and std logger wrapper

Convenient logger interface and wrapper around std logger Interface type Logger interface { Error(err error) Debugf(format string, args ...interface

Denis Mitrofanov 1 Nov 28, 2021
Logger - Simple logger without written with std pkg

Go-Logger Simple usage is: package main

MaskedTrench 2 Jan 2, 2022
Logger - A thin wrapper of uber-go/zap logger for personal project

a thin wraper of uber-go/zap logger for personal project 0. thanks uber-go/zap B

tsingson 0 Jan 11, 2022
Logrus is a structured, pluggable logging for Go.

Logrus is a structured logger for Go (golang), completely API compatible with the standard library logger.

Simon Eskildsen 274 May 25, 2021
Time based rotating file writer

cronowriter This is a simple file writer that it writes message to the specified format path. The file path is constructed based on current date and t

Yuta UEKUSA 46 Nov 4, 2021
Rolling writer is an IO util for auto rolling write in go.

RollingWriter RollingWriter is an auto rotate io.Writer implementation. It can works well with logger. Awesome Go popular log helper New Version v2.0

Arthur Lee 184 Jan 13, 2022
Rotating File Writer

Rotating File writer An io.writer & io.Closer compliant file writer that will always write to the path that you give it, even if somebody deletes/rena

Michael Pearson 34 Jul 12, 2021
A logger, for Go

Go-Log A logger, for Go! It's sort of log and code.google.com/p/log4go compatible, so in most cases can be used without any code changes. Breaking cha

Ian Kent 38 Oct 27, 2021
Simple logger for Go programs. Allows custom formats for messages.

go-logger A simple go logger for easy logging in your programs. Allows setting custom format for messages. Preview Install go get github.com/apsdehal/

Amanpreet Singh 271 Dec 4, 2021
A 12-factor app logger built for performance and happy development

logxi log XI is a structured 12-factor app logger built for speed and happy development. Simpler. Sane no-configuration defaults out of the box. Faste

Mario Gutierrez 349 Dec 30, 2021
Dead simple, super fast, zero allocation and modular logger for Golang

Onelog Onelog is a dead simple but very efficient JSON logger. It is one of the fastest JSON logger out there. Also, it is one of the logger with the

Francois Parquet 401 Jan 4, 2022
A logger for Go SQL database driver without modify existing *sql.DB stdlib usage.

SQLDB-Logger A logger for Go SQL database driver without modify existing *sql.DB stdlib usage. Colored console writer output above only for sample/dev

Sarjono Mukti Aji 203 Jan 16, 2022
xlog is a logger for net/context aware HTTP applications

⚠️ Check zerolog, the successor of xlog. HTTP Handler Logger xlog is a logger for net/context aware HTTP applications. Unlike most loggers, xlog will

Olivier Poitrey 135 Nov 22, 2021
Zero Allocation JSON Logger

Zero Allocation JSON Logger The zerolog package provides a fast and simple logger dedicated to JSON output. Zerolog's API is designed to provide both

Olivier Poitrey 5.8k Jan 18, 2022
A powerful zero-dependency json logger.

ZKits Logger Library About This package is a library of ZKits project. This is a zero-dependency standard JSON log library that supports structured JS

Qingshan Luo 15 Dec 31, 2021
Configurable Logger for Go

Timber! This is a logger implementation that supports multiple log levels, multiple output destinations with configurable formats and levels for each.

DeNA SF 67 Dec 27, 2021
A feature-rich and easy to use logger for golang

A feature-rich and easy to use logger for golang ?? Install ?? Common Logs lumber.Success() lumber.Info() lumber.Debug() lumber.Warning()

Matthew Gleich 47 Jan 3, 2022
A minimal and extensible structured logger

⚠️ PRE-RELEASE ⚠️ DO NOT IMPORT THIS MODULE YOUR PROJECT WILL BREAK package log package log provides a minimal interface for structured logging in ser

Go kit 81 Jan 6, 2022