mlog

package module
v0.0.0-...-2a609cf Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: MPL-2.0 Imports: 6 Imported by: 49

README

Marconi Logger

Overview

Marconi Logger is an application-wide logger and is expected to handle all the logging needs of an application including:

  • logging to multiple files
  • logging to console
  • filtering based on log level

Marconi Logger contains a list of individual log instances, where each one can have its own configurations. Underneath the hood, each log instance is a wrapper around the popular library "logrus".

Example Usage
// initialize logger
func initLogger() {
  mlog.Init("SOME_PATH", "info")
  
  // write to default log
  mlog.GetLogger().Debug("Hello World")
  mlog.GetLogger().Info("Hello World")
  
  // write to file
  logger, _ = mlog.GetLogInstance("FILE_NAME")
  logger.Debug("Hello World")
  logger.Info("Hello World")
}
How to Test

go test

More info on Logrus

https://github.com/sirupsen/logrus

Future Work

More improvements are expected:

  • log rotation
  • setting logging level at file level

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(logDir string, level string)

initialize the logging directory and log level for all log instances

func SetOutputLevel

func SetOutputLevel(level string)

Set the log level of all log instances

Types

type Mlog

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

Marconi Log

func GetLogInstance

func GetLogInstance(name string, optional ...bool) (mlog *Mlog, err error)

Get the log instance by name, if not exist, create a new one, optional parameter specifies whether the log instance outputs to stdout as well as to file or just to file

func GetLogger

func GetLogger() (mlog *Mlog)

Returns the default logger

func (*Mlog) Close

func (mlog *Mlog) Close()

Close the file of a log instance from writing

func (*Mlog) Debug

func (mlog *Mlog) Debug(msg ...interface{})

func (*Mlog) Debugf

func (mlog *Mlog) Debugf(format string, v ...interface{})

func (*Mlog) Error

func (mlog *Mlog) Error(msg ...interface{})

func (*Mlog) Errorf

func (mlog *Mlog) Errorf(format string, v ...interface{})

func (*Mlog) Fatal

func (mlog *Mlog) Fatal(msg ...interface{})

func (*Mlog) Fatalf

func (mlog *Mlog) Fatalf(format string, v ...interface{})

func (*Mlog) Info

func (mlog *Mlog) Info(msg ...interface{})

func (*Mlog) Infof

func (mlog *Mlog) Infof(format string, v ...interface{})

func (*Mlog) Warn

func (mlog *Mlog) Warn(msg ...interface{})

func (*Mlog) Warnf

func (mlog *Mlog) Warnf(format string, v ...interface{})

func (*Mlog) Warning

func (mlog *Mlog) Warning(msg ...interface{})

func (*Mlog) Warningf

func (mlog *Mlog) Warningf(format string, v ...interface{})

Jump to

Keyboard shortcuts

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