package
0.0.1
Repository: https://github.com/pow-duck/httplib.git
Documentation: pkg.go.dev

# README

logs

logs is a Go logs manager. It can use many logs adapters. The repo is inspired by database/sql .

How to install?

go get github.com/Pow-Duck/httplib/logs

What adapters are supported?

As of now this logs support console, file,smtp and conn.

How to use it?

First you must import it

import (
	"github.com/Pow-Duck/httplib/logs"
)

Then init a Log (example with console adapter)

log := logs.NewLogger(10000)
log.SetLogger("console", "")

the first params stand for how many channel

Use it like this:

log.Trace("trace")
log.Info("info")
log.Warn("warning")
log.Debug("debug")
log.Critical("critical")

File adapter

Configure file adapter like this:

log := NewLogger(10000)
log.SetLogger("file", `{"filename":"test.log"}`)

Conn adapter

Configure like this:

log := NewLogger(1000)
log.SetLogger("conn", `{"net":"tcp","addr":":7020"}`)
log.Info("info")

Smtp adapter

Configure like this:

log := NewLogger(10000)
log.SetLogger("smtp", `{"username":"[email protected]","password":"xxxxxxxx","host":"smtp.gmail.com:587","sendTos":["[email protected]"]}`)
log.Critical("sendmail critical")
time.Sleep(time.Second * 30)

# Packages

Package alils implements the SDK(v0.5.0) of Simple Log Service(abbr.
No description provided by the author

# Functions

AccessLog - Format and print access log.
Alert logs a message at alert level.
Async set the beelogger with Async mode and hold msglen messages.
ColorByMethod return color by http code.
ColorByStatus return color by http code 2xx return Green 3xx return White 4xx return Yellow 5xx return Red.
Critical logs a message at critical level.
Debug logs a message at debug level.
Emergency logs a message at emergency level.
EnableFullFilePath enables full file path logging.
EnableFuncCallDepth enable log funcCallDepth.
Error logs a message at error level.
GetBeeLogger returns the default BeeLogger.
No description provided by the author
GetLogger returns the default BeeLogger.
Info compatibility alias for Warning().
Informational logs a message at info level.
NewConn creates new ConnWrite returning as LoggerInterface.
NewConsole creates ConsoleWriter returning as LoggerInterface.
NewLogger returns a new BeeLogger.
Notice logs a message at notice level.
Register makes a log provide available by the provided name.
RegisterFormatter register an formatter.
Reset will remove all the adapter.
ResetColor return reset color.
SetGlobalFormatter sets the global formatter for all log adapters don't forget to register the formatter by invoking RegisterFormatter.
SetLevel sets the global log level used by the simple logger.
SetLogFuncCall set the CallDepth, default is 4.
SetLogFuncCallDepth set log funcCallDepth.
SetLogger sets a new logger.
SetPrefix sets the prefix.
Trace logs a message at trace level.
Warn compatibility alias for Warning().
Warning logs a message at warning level.

# Constants

Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
Name for adapter with beego official support.
RFC5424 log message levels.
RFC5424 log message levels.
RFC5424 log message levels.
RFC5424 log message levels.
RFC5424 log message levels.
Legacy log level constants to ensure backwards compatibility.
RFC5424 log message levels.
RFC5424 log message levels.
Legacy log level constants to ensure backwards compatibility.
Legacy log level constants to ensure backwards compatibility.
RFC5424 log message levels.

# Structs

AccessLogRecord is astruct for holding access log data.
BeeLogger is default logger in beego application.
JLWriter implements beego LoggerInterface and is used to send jiaoliao webhook.
No description provided by the author
PatternLogFormatter provides a quick format method for example: tes := &PatternLogFormatter{Pattern: "%F:%n|%w %t>> %m", WhenFormat: "2006-01-02"} RegisterFormatter("tes", tes) SetGlobalFormatter("tes").
SLACKWriter implements beego LoggerInterface and is used to send jiaoliao webhook.
SMTPWriter implements LoggerInterface and is used to send emails via given SMTP-server.

# Interfaces

No description provided by the author
Logger defines the behavior of a log provider.