dbio

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDB

func CloseDB(db *sql.DB, dbPath string)

CloseDB closes the database and removes the temp file without writing output.

func OpenDB

func OpenDB() (*sql.DB, string, error)

OpenDB reads a serialized sqlite database from stdin (if piped) or creates a fresh one, ensures the standard schema exists, and returns an open *sql.DB along with the temp file path. The caller must call OutputDB or CloseDB when done.

func OutputDB

func OutputDB(db *sql.DB, dbPath string) error

OutputDB writes the database to stdout if piped, or prints a message to stderr if stdout is a terminal. It closes the database and removes the temp file in all cases.

func ZeroFill

func ZeroFill(a string, size int) string

ZeroFill left-pads a string with zeros to the given size.

Types

type Logger

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

Logger writes log entries to both a database table and stderr. INFO and WARN go to the database only. ERROR goes to both.

func NewLogger

func NewLogger(db *sql.DB, component string) *Logger

NewLogger creates a logger that tags entries with the given component name.

func (*Logger) Error

func (l *Logger) Error(args ...any)

Error logs an error message to the database and stderr.

func (*Logger) Fatal

func (l *Logger) Fatal(args ...any)

Fatal logs an error message to the database and stderr, then exits.

func (*Logger) Info

func (l *Logger) Info(args ...any)

Info logs an informational message to the database.

func (*Logger) Warn

func (l *Logger) Warn(args ...any)

Warn logs a warning message to the database.

Jump to

Keyboard shortcuts

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