log

package module
v0.0.0-...-cbc5a95 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2017 License: MIT Imports: 3 Imported by: 1

README

aisola/log

A logging library because all other logging libraries are too complicated.

GoDoc Widget Code Climate Go Report Card MIT license

This comes from searching around for a not complicated logging library and running into this article.

This library is intended to only have two levels and be very a uncomplicated logger for go programs.

Warning

Like any other random code you find on the internet, this package should not be relied upon in important, production systems without thorough testing to ensure that it meets your needs. I wrote this for handling my simple needs and I never expect that it will really be useful for anybody else. It has no tests, and has barely been used.

Installing

go get -u -v github.com/aisola/log

Example

package main

import "github.com/aisola/log"

func main() {
     log.Info("The program is running")
     log.Infof("This is the %s message", "2nd")
     log.Debug("I'll only be written to the log if you've told the logger to.")
     log.Debugf("Hello, %s!", "world")
}

Documentation

Overview

Package log intends to be an extremely simple, lightweight logging library with only what is necessary for decent logging in most golang programs

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = New(os.Stdout)

DefaultLogger is a logger mounted to Stdout.

Functions

func Debug

func Debug(message string)

Debug is a convenience method mounted to DefaultLogger to Logger.Debug.

func Debugf

func Debugf(format string, args ...interface{})

Debugf is a convenience method mounted to DefaultLogger to Logger.Debugf.

func Info

func Info(message string)

Info is a convenience method mounted to DefaultLogger to Logger.Info.

func Infof

func Infof(format string, args ...interface{})

Infof is a convenience method mounted to DefaultLogger to Logger.Infof.

func SetDebug

func SetDebug(status bool)

SetDebug is a convenience method mounted to DefaultLogger to Logger.SetDebug.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is the structure which makes up a place to log.

func New

func New(w io.Writer) *Logger

New will take an io.Writer and return a logger.

func NewMultiLogger

func NewMultiLogger(w ...io.Writer) *Logger

NewMultiLogger is a convenience function to log to multiple sources. This is equivalent to calling New and passing in the result from io.MultiWriter.

func (*Logger) Debug

func (l *Logger) Debug(message string)

Debug writes a basic debug-level message to the logger, then a newline. The message will only write if you have called Logger.SetDebug with true.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf writes a formatted debug-level message to the logger, then a newline. The message will only write if you have called Logger.SetDebug with true.

func (*Logger) Info

func (l *Logger) Info(message string)

Info writes a basic info-level message to the logger, then a newline.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

Infof writes a formatted info-level message to the logger, then a newline.

func (*Logger) SetDebug

func (l *Logger) SetDebug(status bool)

SetDebug sets the log level to write debug messages when called with true, otherwise sets the log level to not write debug messages.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL