logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logger provides structured logging for the DAST crawler.

Index

Constants

View Source
const (
	DebugLevel = zerolog.DebugLevel
	InfoLevel  = zerolog.InfoLevel
	WarnLevel  = zerolog.WarnLevel
	ErrorLevel = zerolog.ErrorLevel
	FatalLevel = zerolog.FatalLevel
)

Log levels.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

Debug logs a debug message using the global logger.

func Debugf

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

Debugf logs a formatted debug message using the global logger.

func Error

func Error(msg string)

Error logs an error message using the global logger.

func Errorf

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

Errorf logs a formatted error message using the global logger.

func Info

func Info(msg string)

Info logs an info message using the global logger.

func Infof

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

Infof logs a formatted info message using the global logger.

func SetGlobal

func SetGlobal(l *Logger)

SetGlobal sets the global logger.

func Warn

func Warn(msg string)

Warn logs a warning message using the global logger.

func Warnf

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

Warnf logs a formatted warning message using the global logger.

Types

type Config

type Config struct {
	Level      Level
	Pretty     bool // Use console writer (colored output)
	Output     io.Writer
	TimeFormat string
	Component  string // Component name (e.g., "crawler", "browser", "queue")
}

Config holds logger configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults.

type Level

type Level = zerolog.Level

Level represents log levels.

func ParseLevel

func ParseLevel(levelStr string) (Level, error)

ParseLevel parses a level string.

type Logger

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

Logger wraps zerolog for structured logging.

func Global

func Global() *Logger

Global returns the global logger.

func New

func New(cfg Config) *Logger

New creates a new logger with the given configuration.

func NewDefault

func NewDefault() *Logger

NewDefault creates a logger with default configuration.

func NewJSON

func NewJSON(level Level) *Logger

NewJSON creates a JSON-only logger (no pretty printing).

func (*Logger) CrawlEvent

func (l *Logger) CrawlEvent(level Level, url string, depth int, workerID int) *zerolog.Event

CrawlEvent logs a crawl-related event with standard fields.

func (*Logger) Debug

func (l *Logger) Debug(msg string)

Debug logs a debug message.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf logs a formatted debug message.

func (*Logger) DiscoveryEvent

func (l *Logger) DiscoveryEvent(discoveryType, url, source string)

DiscoveryEvent logs a discovery event.

func (*Logger) Error

func (l *Logger) Error(msg string)

Error logs an error message.

func (*Logger) ErrorEvent

func (l *Logger) ErrorEvent(err error, url string, operation string)

ErrorEvent logs an error event with context.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

Errorf logs a formatted error message.

func (*Logger) Event

func (l *Logger) Event(level Level) *zerolog.Event

Event returns a zerolog Event for complex logging.

func (*Logger) Fatal

func (l *Logger) Fatal(msg string)

Fatal logs a fatal message and exits.

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...interface{})

Fatalf logs a formatted fatal message and exits.

func (*Logger) Info

func (l *Logger) Info(msg string)

Info logs an info message.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

Infof logs a formatted info message.

func (*Logger) RequestEvent

func (l *Logger) RequestEvent(method, url string, statusCode int, duration time.Duration)

RequestEvent logs an HTTP request event.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel changes the log level.

func (*Logger) StatsEvent

func (l *Logger) StatsEvent(stats map[string]interface{})

StatsEvent logs statistics.

func (*Logger) Warn

func (l *Logger) Warn(msg string)

Warn logs a warning message.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

Warnf logs a formatted warning message.

func (*Logger) WithComponent

func (l *Logger) WithComponent(component string) *Logger

WithComponent returns a new logger with the component field set.

func (*Logger) WithDepth

func (l *Logger) WithDepth(depth int) *Logger

WithDepth returns a new logger with depth field.

func (*Logger) WithDuration

func (l *Logger) WithDuration(d time.Duration) *Logger

WithDuration returns a new logger with duration field.

func (*Logger) WithError

func (l *Logger) WithError(err error) *Logger

WithError returns a new logger with error field.

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *Logger

WithField returns a new logger with an additional field.

func (*Logger) WithFields

func (l *Logger) WithFields(fields map[string]interface{}) *Logger

WithFields returns a new logger with additional fields.

func (*Logger) WithURL

func (l *Logger) WithURL(url string) *Logger

WithURL returns a new logger with URL field.

func (*Logger) WithWorker

func (l *Logger) WithWorker(workerID int) *Logger

WithWorker returns a new logger with worker ID field.

Jump to

Keyboard shortcuts

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