diag

package module
v0.0.0-...-909cb48 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: BSD-3-Clause Imports: 11 Imported by: 17

README

* logger

* Example
#+begin_src go
import "github.com/jaw0/acdiag"

var dl = diag.Logger("encabulator")

dl.Debug("deplenation: %+v", dpl)
dl.Verbose("thing happened")
dl.Fatal("bad things happened: %v", err)

// in/near main
diag.SetConfig(diag.Config{
        ProgName: "proggyd",
        MailTo:   "devteam@company",
        MailFrom: "daemon@company",
        Facility: "local5",
        Debug:    map[string]bool{
                "encabulator": true,
                "api":         true,
        },
})

#+end_src

Documentation

Overview

diagnostics + logging

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bug

func Bug(format string, args ...interface{})

Bug logs a message indicating a bug

func Fatal

func Fatal(format string, args ...interface{})

Fatal logs a message at high priority + terminates the program

func Problem

func Problem(format string, args ...interface{})

Problem logs a message indicating a problem

func SetConfig

func SetConfig(cf Config)

SetConfig sets the config

func SetDebugFlag

func SetDebugFlag(f string, v bool)

SetDebugFlag enables/disables debug logging for a specified section

func Verbose

func Verbose(format string, args ...interface{})

Verbose logs a message at verbose priority

Types

type Config

type Config struct {
	MailTo        string
	MailFrom      string
	MailRateLimit time.Duration
	Sendmail      string
	Facility      string
	ProgName      string
	Debug         map[string]bool
}

Config configures the loggger

type Diag

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

func Logger

func Logger(sect string) *Diag

Logger creates a logger

func (*Diag) Bug

func (d *Diag) Bug(format string, args ...interface{})

Bug logs a message indicating a bug

func (*Diag) Debug

func (d *Diag) Debug(format string, args ...interface{})

Debug logs a message at debug priority

func (*Diag) Fatal

func (d *Diag) Fatal(format string, args ...interface{})

Fatal logs a message at high priority + terminates the program

func (*Diag) Logger

func (d *Diag) Logger(sect string) *Diag

Logger creates a logger

func (*Diag) Problem

func (d *Diag) Problem(format string, args ...interface{})

Problem logs a message indicating a problem

func (*Diag) SetDebugAll

func (d *Diag) SetDebugAll(x bool)

SetDebugAll sets the debugall flag

func (*Diag) SetStderr

func (d *Diag) SetStderr(x bool)

SetStderr enables stderr output

func (*Diag) Verbose

func (d *Diag) Verbose(format string, args ...interface{})

Verbose logs a message at verbose priority

func (*Diag) WithMailFrom

func (d *Diag) WithMailFrom(e string) *Diag

WithMailFrom changes the mail sender

func (*Diag) WithMailTo

func (d *Diag) WithMailTo(e string) *Diag

WithMailTo changes the mail destination

Jump to

Keyboard shortcuts

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