utils

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package utils provides public utility functions for pgsquash.

This package exports commonly needed utility functionality for external tools using pgsquash as a library.

Index

Constants

View Source
const (
	LogLevelDebug = internal_utils.LogLevelDebug
	LogLevelInfo  = internal_utils.LogLevelInfo
	LogLevelWarn  = internal_utils.LogLevelWarn
	LogLevelError = internal_utils.LogLevelError
	LogLevelFatal = internal_utils.LogLevelFatal
)

Log levels available for configuration

Variables

This section is empty.

Functions

func SetDefaultLogger

func SetDefaultLogger(logger *Logger)

SetDefaultLogger sets the global default logger instance. This logger will be used throughout the pgsquash-engine.

Should be called during application initialization before any other operations.

Example:

logger := utils.NewLogger(utils.LogLevelInfo, os.Stdout)
utils.SetDefaultLogger(logger)

Types

type LogLevel

type LogLevel = internal_utils.LogLevel

LogLevel represents logging verbosity levels.

type Logger

type Logger = internal_utils.Logger

Logger provides structured logging functionality. It wraps the internal logger implementation for external use.

func GetDefaultLogger

func GetDefaultLogger() *Logger

GetDefaultLogger returns the global default logger instance. Returns nil if SetDefaultLogger has not been called.

Example:

logger := utils.GetDefaultLogger()
if logger != nil {
    logger.Info("Using default logger")
}

func NewLogger

func NewLogger(level LogLevel, output io.Writer) *Logger

NewLogger creates a new logger instance with the specified level and output.

Parameters:

  • level: The minimum log level to output (Debug, Info, Warning, Error)
  • output: Where to write log messages (typically os.Stdout or os.Stderr)

Example:

logger := utils.NewLogger(utils.LogLevelInfo, os.Stdout)
logger.Info("Application started")

Jump to

Keyboard shortcuts

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