log

package module
v0.22.8 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: BSD-3-Clause Imports: 10 Imported by: 131

README

log

This is an attempt to modify the default golang 'log'. Because the 'gui' toolkit could be either ncurses or something like gtk, 'log' is an attempt to be smart about changing STDOUT on the fly.

  • add meaningful shortcuts like log.Info(), log.Warn(), log.Error() etc
  • add flags to enable & disable output on a per-gomodule basis
  • add http flag to switch stdout to http socket
  • compatible with changing import 'log' to import 'go.wit.com/log'
  • should also be compatible with changing import 'fmt' to import fmt 'go.wit.com/log'

Notes & Goals:

  • be a complete droplet replacement for golang 'log'
  • provide an example of how the stdlib 'log' could be changed

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool, a ...any)

func CaptureMode added in v0.22.5

func CaptureMode(w io.Writer)

func DaemonMode added in v0.22.1

func DaemonMode(b bool)

func DaemonShow added in v0.22.1

func DaemonShow() bool

func Error

func Error(err error, a ...any)

func Exit

func Exit(a ...any)

exit() # yep. exits. I guess everything must be fine exit(3) # I guess 3 it is then exit("dont like apples") # ok. I'll make a note of that

func Fatal

func Fatal(s string, a ...any)

func Fatalf

func Fatalf(s string, a ...any)

func Fatalln added in v0.5.5

func Fatalln(a ...any)

func HttpMode added in v0.22.2

func HttpMode(w http.ResponseWriter)

func Info

func Info(a ...any)

func Infof

func Infof(s string, a ...any)

func Log

func Log(f *LogFlag, a ...any)

func Logf

func Logf(f *LogFlag, s string, a ...any)

func Printf

func Printf(s string, a ...any)

func Println

func Println(a ...any)

func ProcessFlags

func ProcessFlags(callback func(*LogFlag))

TODO, switch to this. maybe.

func SetAll

func SetAll(b bool)

set all the flags

func SetDefaults

func SetDefaults()

set all the flags

func SetTmpOLD added in v0.20.4

func SetTmpOLD()

start writing all the logging to a tmp file

func Sleep

func Sleep(a ...any)

sleep() # you know what this does? sleeps for 1 second. yep. dump. easy. sleep(.1) # you know what this does? yes, it sleeps for 1/10th of a second

func Spew

func Spew(b any, a ...any)

func Sprint added in v0.22.1

func Sprint(a ...any) string

func Sprintf added in v0.22.1

func Sprintf(s string, a ...any) string

func Sprintln added in v0.22.1

func Sprintln(a ...any) string

func UnsetTmp added in v0.17.0

func UnsetTmp()

start writing all the logging to a tmp file

func Verbose

func Verbose(a ...any)

func Warn

func Warn(a ...any)

Types

type LogFlag

type LogFlag struct {
	// contains filtered or unexported fields
}
var ERROR *LogFlag // toggles log.Warn() (true by default)
var INFO *LogFlag // toggles log.Info()
var PRINTLN *LogFlag // toggles log.Println() (true by default)
var SPEW *LogFlag // toggles log.Spew()
var VERBOSE *LogFlag // toggles log.Verbose()
var WARN *LogFlag // toggles log.Warn() (true by default)

func NewFlag

func NewFlag(name string, b bool, full, short, desc string) *LogFlag

this is what the current log.SetFlag() function should become

func ShowFlags

func ShowFlags() []*LogFlag

this bypasses all checks and _always_ logs the info to STDOUT is this a bad idea? Probably not.... TODO: returning []*LogFlag is not safe and access must be locked but this is only used by the log debugging window at this time

func (*LogFlag) Bool added in v0.5.6

func (f *LogFlag) Bool() bool

probably a better name than Get() switch to this

func (*LogFlag) Get

func (f *LogFlag) Get() bool

returns the value of the flag

func (*LogFlag) GetDefault added in v0.5.6

func (f *LogFlag) GetDefault() bool

returns the description of the flag

func (*LogFlag) GetDesc

func (f *LogFlag) GetDesc() string

returns the description of the flag

func (*LogFlag) GetName

func (f *LogFlag) GetName() string

returns the name of the flag

func (*LogFlag) GetSubsystem

func (f *LogFlag) GetSubsystem() string

returns the subsystem of the flag

func (*LogFlag) Ok

func (f *LogFlag) Ok() bool

simply protects against panic() by making sure it exists.

func (*LogFlag) SetBool added in v0.5.6

func (f *LogFlag) SetBool(b bool)

func (*LogFlag) SetDefault

func (f *LogFlag) SetDefault()

restores flag to it's default value

Jump to

Keyboard shortcuts

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