sqlog

package
v1.0.25 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SQLWriter

type SQLWriter struct {
	log.LogFilter
	log.BatchWriter

	Driver    string
	Dsn       string
	Statement string

	ConnMaxIdleTime time.Duration
	ConnMaxLifeTime time.Duration
	// contains filtered or unexported fields
}

SQLWriter implements log Writer Interface and batch send log messages to database. Prepare:

CREATE TABLE logs (
	id serial NOT NULL,
	time timestamp with time zone NOT NULL,
	level char(1) NOT NULL,
	msg text NOT NULL,
	file text NOT NULL,
	line integer NOT NULL,
	func text NOT NULL,
	trace text NOT NULL);

Driver: postgres Statement: "INSERT INTO sqlogs (time, level, msg, file, line, func, trace) VALUES ($1, $2, $3, $4, $5, $6, $7)" Parameter: "%t %p %m %S %L %F %T"

func (*SQLWriter) Close

func (sw *SQLWriter) Close()

Close flush and close the writer

func (*SQLWriter) Flush

func (sw *SQLWriter) Flush()

Flush flush cached events

func (*SQLWriter) SetConnMaxIdleTime

func (sw *SQLWriter) SetConnMaxIdleTime(duration string) error

SetConnMaxIdleTime set ConnMaxIdleTime

func (*SQLWriter) SetConnMaxLifeTime

func (sw *SQLWriter) SetConnMaxLifeTime(duration string) error

SetConnMaxLifeTime set ConnMaxLifeTime

func (*SQLWriter) SetParameter

func (sw *SQLWriter) SetParameter(format string)

SetParameter set sql statement parameter %t: event time %c: logger name %p: log level prefix %l: log level string %x{key}: logger property %S: caller source file name %L: caller source line number %F: caller function name %T: caller stack trace %m: message %M{msg}: custom message

func (*SQLWriter) Write

func (sw *SQLWriter) Write(le *log.Event) error

Write cache log message, flush if needed

Jump to

Keyboard shortcuts

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