message

package module
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2023 License: MIT Imports: 9 Imported by: 22

README

message

Not everyone needs configured logging.

go get github.com/sirkon/message

This library is primarily for command line short lived utilities where the time output is not needed. Only message itself.

What is supported:

  • Leveled output distincted with colors

    level color methods
    critical bold red Critical, Criticalf, Fatal, Fatalf
    error red Error, Errorf
    warning yellow Warning, Warningf
    notice green Notice, Noticef
    info reset Info, Infof
    debug cyan Debug, Debugf
  • Code location output - DEBUG environment variable must be set into not empty value

Usage example
package main

import "github.com/sirkon/message"

func main() {
	message.Notice("Hello world!")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFatalHook added in v1.6.0

func AddFatalHook(f func())

AddFatalHook adds a function to execute before the os.Exit(1) in Fatal family of functions.

func Critical

func Critical(data ...interface{})

Critical print red message and exit

func Criticalf

func Criticalf(format string, data ...interface{})

Criticalf print yellow formatted message

func Debug

func Debug(data ...interface{})

Debug print yellow message

func Debugf

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

Debugf print yellow formatted message

func Error

func Error(data ...interface{})

Error print red message and exit

func Errorf

func Errorf(format string, data ...interface{})

Errorf print yellow formatted message

func Fatal

func Fatal(data ...interface{})

Fatal print red message and exit

func Fatalf

func Fatalf(format string, data ...interface{})

Fatalf print yellow formatted message

func Info

func Info(data ...interface{})

Info print yellow message

func Infof

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

Infof print yellow formatted message

func Notice

func Notice(data ...interface{})

Notice print yellow message

func Noticef

func Noticef(format string, data ...interface{})

Noticef print yellow formatted message

func RemoveFatalHooks added in v1.6.0

func RemoveFatalHooks()

RemoveFatalHooks clears all fatal hooks

func SetDebug

func SetDebug(status bool)

SetDebug sets debug on/off depending on the status

func SetDest

func SetDest(d io.Writer)

SetDest sets print destination. Default destination is os.Stderr

func UseColor

func UseColor(decision bool)

UseColor enables/disables color output depending on the decision's value

func Warning

func Warning(data ...interface{})

Warning print yellow message

func Warningf

func Warningf(format string, data ...interface{})

Warningf print yellow formatted message

Types

type Color

type Color string

Color ...

type ColorInfo

type ColorInfo struct {
	Text string
	Code int
	// contains filtered or unexported fields
}

ColorInfo ...

func (*ColorInfo) Extract

func (p *ColorInfo) Extract(line string) (bool, error)

Extract ...

Jump to

Keyboard shortcuts

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