holmes

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 1 Imported by: 1

README

Holmes

How to use

Debug level
package main

import github.com/quantfall/holmes

func main(){
  h := holmes.New("debug", "example")
  h.Info("%s using function: %s", "Output", "Info")
  h.Error("%s using function: %s", "Output", "Error")
  h.Debug("%s using function: %s", "Output", "Debug")
  h.FatalError("%s using function: %s", "Output", "FatalError")
}

Output:

YYYY/MM/DD HH:MM:SS example INFO: Output using function: Info
YYYY/MM/DD HH:MM:SS example ERROR: Output using function: Error
YYYY/MM/DD HH:MM:SS example DEBUG: Output using function: Debug
YYYY/MM/DD HH:MM:SS example PANIC: Output using function: FatalError
Info level
package main

import github.com/quantfall/holmes

func main(){
  h := holmes.New("info", "example")
  h.Info("%s using function: %s", "Output", "Info")
  h.Error("%s using function: %s", "Output", "Error")
  h.Debug("%s using function: %s", "Output", "Debug")
  h.FatalError("%s using function: %s", "Output", "FatalError")
}

Output:

YYYY/MM/DD HH:MM:SS example INFO: Output using function: Info
YYYY/MM/DD HH:MM:SS example ERROR: Output using function: Error
YYYY/MM/DD HH:MM:SS example PANIC: Output using function: FatalError

h.Debug was ignored because the log level is info.

Error level
package main

import github.com/quantfall/holmes

func main(){
  h := holmes.New("error", "example")
  h.Info("%s using function: %s", "Output", "Info")
  h.Error("%s using function: %s", "Output", "Error")
  h.Debug("%s using function: %s", "Output", "Debug")
  h.FatalError("%s using function: %s", "Output", "FatalError")
}

Output:

YYYY/MM/DD HH:MM:SS example ERROR: Output using function: Error
YYYY/MM/DD HH:MM:SS example PANIC: Output using function: FatalError

h.Debug and h.Info were ignored because the log level is error.

When using the function FatalError the program will close with an error code.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	Level  string
	Module string
}

func New

func New(level, module string) *Logger

func (Logger) Debug

func (c Logger) Debug(message string, args ...interface{})

func (Logger) Error

func (c Logger) Error(message string, args ...interface{})

func (Logger) FatalError

func (c Logger) FatalError(message string, args ...interface{})

func (Logger) Info

func (c Logger) Info(message string, args ...interface{})

Jump to

Keyboard shortcuts

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