logger

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: MIT Imports: 3 Imported by: 3

README

logger

Go Quality Report GoDoc

Library to manage a logger easily

Getting started

Installation

To install Marathon package, you need to install Go and set your Go workspace first.

1 - The first need Go installed (version 1.13+ is required). Then you can use the below Go command to install logger

$ go get -u github.com/dotWicho/logger

And then Import it in your code:

package main

import "github.com/dotWicho/logger"

Or

2 - Use as module in you project (go.mod file):

module myapp

go 1.13

require (
	github.com/dotWicho/logger v1.0.0
)

Usage

package main

import "github.com/dotWicho/logger"

func main () {

	// We define some vars
	buffer := &bytes.Buffer{}

	// Try to create Logger
	_logger := NewLogger(true)
	_logger.SetLevel(logrus.InfoLevel)

	// Some lines to _logger
	_logger.Info("This line appears on console? %v", true)
	_logger.Info("Another line with number %d", 22)

	_logger.Warn("This line appears on console? %v", true)
	_logger.Warn("Another line with number %d", 22)
}

Console Output:
INFO[2020-06-30 17:20:29] This line appears on console? true           
INFO[2020-06-30 17:20:29] Another line with number 22    
WARN[2020-06-30 17:20:29] This line appears on console? true           
WARN[2020-06-30 17:20:29] Another line with number 22          

Contributing

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StandardLogger

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

StandardLogger enforces specific log message formats

func NewLogger

func NewLogger(testEnv bool) *StandardLogger

NewLogger initializes the standard logger

func (*StandardLogger) Debug

func (sl *StandardLogger) Debug(format string, v ...interface{})

Debug is a standard debug logger

func (*StandardLogger) Error

func (sl *StandardLogger) Error(format string, v ...interface{})

Error is a standard error logger

func (*StandardLogger) Info

func (sl *StandardLogger) Info(format string, v ...interface{})

Info is a standard info logger

func (*StandardLogger) SetLevel

func (sl *StandardLogger) SetLevel(level logrus.Level)

SetLevel permit change the Logger Level

func (*StandardLogger) SetOutput

func (sl *StandardLogger) SetOutput(out io.Writer)

SetOutput permit change the Logger Out

func (*StandardLogger) Warn

func (sl *StandardLogger) Warn(format string, v ...interface{})

Warn is a standard warning logger

Jump to

Keyboard shortcuts

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