All Projects → go-log → Log

go-log / Log

Licence: mit
A universal log interface

Programming Languages

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

Labels

Projects that are alternatives of or similar to Log

Angle Grinder
Slice and dice logs on the command line
Stars: ✭ 1,118 (+1351.95%)
Mutual labels:  logging
Xunit Logging
Logging extensions for xunit
Stars: ✭ 69 (-10.39%)
Mutual labels:  logging
Loguru
Python logging made (stupidly) simple
Stars: ✭ 10,510 (+13549.35%)
Mutual labels:  logging
Class Logger
Boilerplate-free decorator-based class logging
Stars: ✭ 64 (-16.88%)
Mutual labels:  logging
Litter
Litter is a pretty printer library for Go data structures to aid in debugging and testing.
Stars: ✭ 1,137 (+1376.62%)
Mutual labels:  logging
Sejil
Capture, view and filter your ASP.net core log events right from your app
Stars: ✭ 70 (-9.09%)
Mutual labels:  logging
Logvac
Simple, lightweight, api-driven log aggregation service with realtime push capabilities and historical persistence.
Stars: ✭ 61 (-20.78%)
Mutual labels:  logging
Laravel Log To Db
Custom Laravel and Lumen 5.6+ Log channel handler that can store log events to SQL or MongoDB databases. Uses Laravel/Monolog native logging functionality.
Stars: ✭ 76 (-1.3%)
Mutual labels:  logging
Ring Logger
Log ring requests & responses using your favorite logging backend
Stars: ✭ 66 (-14.29%)
Mutual labels:  logging
Logback Slack Appender
Logback appender for Slack messenger
Stars: ✭ 73 (-5.19%)
Mutual labels:  logging
Cookiecutter Pyramid Talk Python Starter
An opinionated Cookiecutter template for creating Pyramid web applications starting way further down the development chain. This cookiecutter template will create a new Pyramid web application with email, sqlalchemy, rollbar, and way more integrated.
Stars: ✭ 64 (-16.88%)
Mutual labels:  logging
Logging Log4j2
Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback's architecture.
Stars: ✭ 1,133 (+1371.43%)
Mutual labels:  logging
Logbert
Logbert is an advanced log message viewer for log4net, log4j and others.
Stars: ✭ 70 (-9.09%)
Mutual labels:  logging
Terraform Modules
Reusable Terraform modules
Stars: ✭ 63 (-18.18%)
Mutual labels:  logging
Flutter Boilerplate Project
A boilerplate project created in flutter using MobX and Provider.
Stars: ✭ 1,194 (+1450.65%)
Mutual labels:  logging
Node Draftlog
📜 Create updatable log lines into the terminal, and give life to your logs!
Stars: ✭ 1,117 (+1350.65%)
Mutual labels:  logging
Android Filelogger
A general-purpose logging library with built-in support to save logs to file efficiently.
Stars: ✭ 70 (-9.09%)
Mutual labels:  logging
Mrbutler
Reactive Android App Permissions API with delegates and logging
Stars: ✭ 77 (+0%)
Mutual labels:  logging
Evergreen
Most natural Swift logging
Stars: ✭ 75 (-2.6%)
Mutual labels:  logging
What
Debug-level logging for developers (only!)
Stars: ✭ 73 (-5.19%)
Mutual labels:  logging

Log GoDoc

Log is a logging interface for Go. That's it. Pass around the interface.

Rationale

Users want to standardise logging. Sometimes libraries log. We leave the underlying logging implementation to the user while allowing libraries to log by simply expecting something that satisfies the Logger interface. This leaves the user free to pre-configure structure, output, etc.

Interface

The interface is minimalistic on purpose:

type Logger interface {
    Log(v ...interface{})
    Logf(format string, v ...interface{})
}

For more motivation for this minimal interface, see Dave Cheney's blog post.

Implementations

Libraries will only need the Logger interface, although they may choose to use the nest package to create subloggers with additional context.

Calling code will need to create a Logger interface, and there are a number of implementations and wrappers available to make that easy:

  • capture is an implementation that saves logged lines in memory. It is especially useful for unit tests that want to check for logged messages.
  • fmt is an implementation wrapping an io.Writer like os.Stdout. It uses fmt.Sprint and Sprintf to generate the logged lines.
  • info is an implementation wrapping Info and Infof calls. It can be used to wrap implementations like glog.Verbose and logrus.Entry.
  • print is an implementation wrapping Print and Printf calls. It can be used to wrap implementations like glog.Verbose.
  • log is an implementation wrapping log.Print and log.Printf.

Outside of this repository, there are additional wrappers for:

The Logger interface is also simple enough to make writing your own implementation or wrapper very straightforward.

Example

Pre-configure a logger using WithFields and pass it as an option to a library:

import (
	"github.com/go-log/log/print"
	"github.com/lib/foo"
	"github.com/sirupsen/logrus"
)

logger := print.New(logrus.WithFields(logrus.Fields{
	"library": "github.com/lib/foo",
}))

f := foo.New(logger)

Related projects

github.com/go-logr/logr is a similar interface approach to logging, although the logr.Logger interface is more elaborate.

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