logging

package
v0.1.0-preview.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CategoryMoongate for moongate system logs (rendering, animation, travel)
	CategoryMoongate = "moongate"

	// CategoryConversation for semantic NPC conversation processing
	CategoryConversation = "conversation"

	// CategoryAI for NPC AI, pathfinding, and behavior logs
	CategoryAI = "ai"

	// CategoryAudio for audio system, music, and sound effect logs
	CategoryAudio = "audio"

	// CategoryConfig for configuration loading and validation logs
	CategoryConfig = "config"

	// CategoryUI for user interface, widgets, and dialog logs
	CategoryUI = "ui"

	// CategoryGameState for game state management and save/load operations
	CategoryGameState = "gamestate"

	// CategoryCombat for combat system and battle mechanics
	CategoryCombat = "combat"

	// CategoryMovement for player and NPC movement, collision detection
	CategoryMovement = "movement"

	// CategoryInventory for inventory management and item operations
	CategoryInventory = "inventory"

	// CategorySprites for sprite loading, animation, and rendering
	CategorySprites = "sprites"

	// CategorySystem for low-level system operations and initialization
	CategorySystem = "system"

	// CategoryData for data loading, parsing, and reference management
	CategoryData = "data"

	// CategoryInput for input handling and user commands
	CategoryInput = "input"

	// CategoryRendering for rendering, graphics, and visual effects
	CategoryRendering = "rendering"

	// CategoryValidation for validation, bounds checking, and integrity checks
	CategoryValidation = "validation"

	// CategoryPerformance for performance monitoring and profiling
	CategoryPerformance = "performance"

	// CategoryLighthouse for lighthouse rotation and lighting system
	CategoryLighthouse = "lighthouse"
)

LogCategory constants for consistent categorization across the codebase These categories help organize and filter log messages by functional area

Variables

This section is empty.

Functions

func Debug

func Debug(category string, format string, args ...interface{})

Debug logs a debug message using the global logger

func Error

func Error(category string, format string, args ...interface{})

Error logs an error message using the global logger

func Fatal

func Fatal(category string, format string, args ...interface{})

Fatal logs a fatal message using the global logger

func GetAllCategories

func GetAllCategories() []string

GetAllCategories returns all available log categories for configuration UI

func Info

func Info(category string, format string, args ...interface{})

Info logs an info message using the global logger

func IsCategoryEnabled

func IsCategoryEnabled(category string) bool

IsCategoryEnabled checks if a category is enabled

func IsGlobalEnabled

func IsGlobalEnabled() bool

IsGlobalEnabled returns the global logging enabled state

func IsStdoutEnabled

func IsStdoutEnabled() bool

IsStdoutEnabled returns stdout logging state

func SetCategoryEnabled

func SetCategoryEnabled(category string, enabled bool)

SetCategoryEnabled sets a category's enabled state

func SetGlobalEnabled

func SetGlobalEnabled(enabled bool)

SetGlobalEnabled sets the global logging enabled state

func SetStdoutEnabled

func SetStdoutEnabled(enabled bool)

SetStdoutEnabled sets stdout logging state

func Warn

func Warn(category string, format string, args ...interface{})

Warn logs a warning message using the global logger

Types

type Entry

type Entry struct {
	Sequence  uint64    `json:"sequence"`
	Timestamp time.Time `json:"timestamp"`
	Level     string    `json:"level"`
	Category  string    `json:"category"`
	Message   string    `json:"message"`
}

Entry is one structured categorized log record retained for diagnostics.

type EntryBatch

type EntryBatch struct {
	Entries        []Entry `json:"entries"`
	NextCursor     uint64  `json:"nextCursor"`
	OldestSequence uint64  `json:"oldestSequence"`
	NewestSequence uint64  `json:"newestSequence"`
	Dropped        uint64  `json:"dropped"`
	HasMore        bool    `json:"hasMore"`
}

EntryBatch is an independent cursor snapshot from the bounded log buffer.

type LogLevel

type LogLevel int

LogLevel represents the importance/severity of a log message

const (
	// DEBUG level for detailed diagnostic information, typically only visible during development
	DEBUG LogLevel = iota

	// INFO level for general informational messages that highlight application progress
	INFO

	// WARN level for potentially harmful situations that don't prevent operation
	WARN

	// ERROR level for error events that still allow the application to continue
	ERROR

	// FATAL level for severe error events that will likely abort the application
	FATAL
)

func ParseLogLevel

func ParseLogLevel(level string) LogLevel

ParseLogLevel converts a string to a LogLevel

func (LogLevel) String

func (l LogLevel) String() string

String returns the string representation of the log level

type Logger

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

Logger is the main logging interface that handles categorized, leveled logging

func GetGlobalLogger

func GetGlobalLogger() *Logger

GetGlobalLogger returns the global logger instance

func NewLogger

func NewLogger() *Logger

NewLogger creates a new logger instance with default settings

func (*Logger) Debug

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

Debug logs a debug message

func (*Logger) EntriesAfter

func (l *Logger) EntriesAfter(cursor uint64, limit int) EntryBatch

EntriesAfter returns copied records newer than cursor without advancing other readers.

func (*Logger) Error

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

Error logs an error message

func (*Logger) Fatal

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

Fatal logs a fatal message

func (*Logger) GetCategoryStates

func (l *Logger) GetCategoryStates() map[string]bool

GetCategoryStates returns the current state of all categories for saving

func (*Logger) GetMinLevel

func (l *Logger) GetMinLevel() LogLevel

GetMinLevel returns the current minimum log level

func (*Logger) Info

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

Info logs an info message

func (*Logger) IsCategoryEnabled

func (l *Logger) IsCategoryEnabled(category string) bool

IsCategoryEnabled returns whether a specific category is enabled

func (*Logger) IsEnabled

func (l *Logger) IsEnabled() bool

IsEnabled returns the global logging enabled state

func (*Logger) IsStdoutEnabled

func (l *Logger) IsStdoutEnabled() bool

IsStdoutEnabled returns whether stdout logging is enabled

func (*Logger) LoadConfigurationFromMap

func (l *Logger) LoadConfigurationFromMap(config map[string]interface{})

LoadConfigurationFromMap loads logging settings from a configuration map

func (*Logger) Log

func (l *Logger) Log(level LogLevel, category string, format string, args ...interface{})

Log logs a message with the specified level and category

func (*Logger) SaveConfigurationToMap

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

SaveConfigurationToMap saves current logging settings to a configuration map

func (*Logger) SetCategoryEnabled

func (l *Logger) SetCategoryEnabled(category string, enabled bool)

SetCategoryEnabled sets the enabled state for a specific category

func (*Logger) SetCategoryStates

func (l *Logger) SetCategoryStates(states map[string]bool)

SetCategoryStates sets the state of all categories (for loading from config)

func (*Logger) SetEnabled

func (l *Logger) SetEnabled(enabled bool)

SetEnabled sets the global logging enabled state

func (*Logger) SetMinLevel

func (l *Logger) SetMinLevel(level LogLevel)

SetMinLevel sets the minimum log level to output

func (*Logger) SetStdoutEnabled

func (l *Logger) SetStdoutEnabled(enabled bool)

SetStdoutEnabled sets whether logs should be output to stdout

func (*Logger) Warn

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

Warn logs a warning message

Jump to

Keyboard shortcuts

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