boot

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package boot provides application bootstrap, configuration lifecycle management, and logging initialization for Rays.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BootLoader

type BootLoader struct {
	*config.Config
	// contains filtered or unexported fields
}

BootLoader coordinates application initialization by orchestrating configuration loading, logging setup, and dependency service registration across bootstrap phases.

func NewBootLoader

func NewBootLoader() *BootLoader

NewBootLoader creates and initializes a new BootLoader instance configured with default logging properties and a quiet error-level logger for initial bootstrap.

func (*BootLoader) Boot

func (this *BootLoader) Boot() Error

Boot executes the bootstrap sequence: 1. Initializes configuration files and profiles in a quiet phase. 2. Extracts and unmarshals the "rays.logging" configuration section to reconfigure the logger. 3. Registers the configured logger in the global services registry. 4. Re-initializes the configuration container with full logging enabled.

Returns an error if configuration parsing or unmarshaling fails.

func (*BootLoader) Logger

func (this *BootLoader) Logger() Logging

Logger returns the root application logger as a core.Logging instance.

func (*BootLoader) LoggerForClass

func (this *BootLoader) LoggerForClass(class any) Logging

LoggerForClass returns a specialized core.Logging instance configured for the package or type of the provided struct pointer, respecting package-specific log level overrides.

func (*BootLoader) LoggerForType

func (this *BootLoader) LoggerForType(rtype reflect.Type) Logging

LoggerForType returns a specialized core.Logging instance configured for the provided reflect.Type, applying the most specific log level override defined for its package path or type.

func (*BootLoader) LoggerForTypes

func (this *BootLoader) LoggerForTypes(types ...reflect.Type) Logging

LoggerForTypes returns a specialized core.Logging instance configured for the first matching reflect.Type among candidate types, applying the most specific log level override.

func (*BootLoader) LoggingProperties

func (this *BootLoader) LoggingProperties() *LoggingProperties

LoggingProperties returns the unmarshaled logging configuration properties populated during the bootstrap sequence, or nil if Boot has not yet been invoked.

func (*BootLoader) Reset

func (this *BootLoader) Reset()

Reset restores the BootLoader, its underlying configuration container, and logging state back to their initial unbooted condition.

func (*BootLoader) SetLoggingHandler

func (this *BootLoader) SetLoggingHandler(handler func(io.Writer, *slog.HandlerOptions) slog.Handler)

SetLoggingHandler sets a custom logging handler factory function to override the default slog handler constructed during bootstrap.

type LogColor

type LogColor struct {
	Enum[LogColor]
	AUTO,
	ON,
	OFF Enum[LogColor]
}

LogColor defines the enumeration of terminal ANSI color output options (AUTO, ON, OFF).

func (LogColor) Apply

func (this LogColor) Apply(lg *logger.Logger)

Apply configures the ANSI color output mode on the given logger based on the LogColor setting.

type LogHandler

type LogHandler struct {
	Enum[LogHandler]
	DEFAULT,
	JSON,
	TEXT,
	ECS,
	GELF,
	LOGSTASH,
	CUSTOM Enum[LogHandler]
}

LogHandler defines the enumeration of supported logging handler implementations.

func (*LogHandler) Handler

func (this *LogHandler) Handler(format ...string) func(io.Writer, *slog.HandlerOptions) slog.Handler

Handler returns a factory function that constructs the slog.Handler corresponding to this LogHandler option.

type LogLevel

type LogLevel struct {
	Enum[LogLevel]
	INFO,
	TRACE,
	DEBUG,
	WARN,
	ERROR,
	FATAL Enum[LogLevel]
}

LogLevel defines the enumeration of supported logging severity levels.

func (*LogLevel) Level

func (this *LogLevel) Level() slog.Level

Level converts the LogLevel enumeration into the corresponding slog.Level value.

type LoggingProperties

type LoggingProperties struct {
	ConfigurationProperties `Name:"rays.logging"`
	// contains filtered or unexported fields
}

LoggingProperties holds configuration properties under the "rays.logging" namespace.

func (*LoggingProperties) AddSource

func (this *LoggingProperties) AddSource() bool

AddSource reports whether caller source file and line information should be added to records.

func (*LoggingProperties) Color

func (this *LoggingProperties) Color() LogColor

Color returns the configured ANSI color output mode, mirroring LogColor.

func (*LoggingProperties) Format

func (this *LoggingProperties) Format() string

Format returns the pattern format string configured for custom log handlers.

func (*LoggingProperties) LogColor

func (this *LoggingProperties) LogColor() LogColor

LogColor returns the configured ANSI color output mode.

func (*LoggingProperties) LogHandler

func (this *LoggingProperties) LogHandler() LogHandler

LogHandler returns the configured log handler type.

func (*LoggingProperties) LogLevel

func (this *LoggingProperties) LogLevel() LogLevel

LogLevel returns the configured logging severity level.

func (*LoggingProperties) MapLevels

func (this *LoggingProperties) MapLevels() map[string]LogLevel

MapLevels returns the mapping of package paths or logger names to their configured log levels.

Directories

Path Synopsis
Package config provides hierarchical application configuration loading, profile merging, overrides, type conversion, unmarshaling, and validation for Rays.
Package config provides hierarchical application configuration loading, profile merging, overrides, type conversion, unmarshaling, and validation for Rays.
Package logger provides structured logging facilities with custom log levels, pattern layouts, ANSI color support, and slog integration for Rays.
Package logger provides structured logging facilities with custom log levels, pattern layouts, ANSI color support, and slog integration for Rays.

Jump to

Keyboard shortcuts

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