Documentation
¶
Overview ¶
Package logrus provides benchmarking tools for comparing Logrus and Bolt performance.
Package logrus provides compatibility layer and migration tools for Logrus users.
Package logrus provides examples demonstrating migration from Logrus to Bolt.
Package logrus provides code transformation tools for migrating from Logrus to Bolt.
Index ¶
- Variables
- func AddHook(hook Hook)
- func BenchmarkBoltComplexStructure(b *testing.B)
- func BenchmarkBoltErrorLogging(b *testing.B)
- func BenchmarkBoltSimpleLogging(b *testing.B)
- func BenchmarkBoltStructuredLogging(b *testing.B)
- func BenchmarkBoltWithContext(b *testing.B)
- func BenchmarkLogrusComplexStructure(b *testing.B)
- func BenchmarkLogrusErrorLogging(b *testing.B)
- func BenchmarkLogrusSimpleLogging(b *testing.B)
- func BenchmarkLogrusStructuredLogging(b *testing.B)
- func BenchmarkLogrusWithContext(b *testing.B)
- func ConcurrentLoggingBenchmark()
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Debugln(args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func ExampleBasicLogging()
- func ExampleCompatibilityLayer()
- func ExampleContextLogging()
- func ExampleErrorHandling()
- func ExampleFieldTypes()
- func ExampleFormatterMigration()
- func ExampleFullMigrationWorkflow()
- func ExampleHookMigration()
- func ExampleLevelBasedLogging()
- func ExampleLoggerConfiguration()
- func ExampleMigrationSteps()
- func ExamplePerformanceComparison()
- func ExampleStructuredLogging()
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalln(args ...interface{})
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Infoln(args ...interface{})
- func IsLevelEnabled(level Level) bool
- func MemoryUsageTest()
- func Panic(args ...interface{})
- func Panicf(format string, args ...interface{})
- func Panicln(args ...interface{})
- func Print(args ...interface{})
- func PrintPerformanceResults(results []PerformanceComparisonResult)
- func Printf(format string, args ...interface{})
- func Println(args ...interface{})
- func SetFormatter(formatter Formatter)
- func SetLevel(level Level)
- func SetOutput(out io.Writer)
- func Sprint(args ...interface{}) string
- func Sprintf(format string, args ...interface{}) string
- func Sprintln(args ...interface{}) string
- func Trace(args ...interface{})
- func Tracef(format string, args ...interface{})
- func Traceln(args ...interface{})
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func Warning(args ...interface{})
- func Warningf(format string, args ...interface{})
- func Warningln(args ...interface{})
- func Warnln(args ...interface{})
- type BenchmarkReport
- type BenchmarkSummary
- type CustomHandler
- type Entry
- func (entry *Entry) Debug(args ...interface{})
- func (entry *Entry) Debugf(format string, args ...interface{})
- func (entry *Entry) Debugln(args ...interface{})
- func (entry *Entry) Error(args ...interface{})
- func (entry *Entry) Errorf(format string, args ...interface{})
- func (entry *Entry) Errorln(args ...interface{})
- func (entry *Entry) Fatal(args ...interface{})
- func (entry *Entry) Fatalf(format string, args ...interface{})
- func (entry *Entry) Fatalln(args ...interface{})
- func (entry *Entry) Info(args ...interface{})
- func (entry *Entry) Infof(format string, args ...interface{})
- func (entry *Entry) Infoln(args ...interface{})
- func (entry *Entry) Panic(args ...interface{})
- func (entry *Entry) Panicf(format string, args ...interface{})
- func (entry *Entry) Panicln(args ...interface{})
- func (entry *Entry) Print(args ...interface{})
- func (entry *Entry) Printf(format string, args ...interface{})
- func (entry *Entry) Println(args ...interface{})
- func (entry *Entry) String() string
- func (entry *Entry) Trace(args ...interface{})
- func (entry *Entry) Tracef(format string, args ...interface{})
- func (entry *Entry) Traceln(args ...interface{})
- func (entry *Entry) Warn(args ...interface{})
- func (entry *Entry) Warnf(format string, args ...interface{})
- func (entry *Entry) Warning(args ...interface{})
- func (entry *Entry) Warningf(format string, args ...interface{})
- func (entry *Entry) Warningln(args ...interface{})
- func (entry *Entry) Warnln(args ...interface{})
- func (entry *Entry) WithContext(ctx context.Context) *Entry
- func (entry *Entry) WithError(err error) *Entry
- func (entry *Entry) WithField(key string, value interface{}) *Entry
- func (entry *Entry) WithFields(fields Fields) *Entry
- func (entry *Entry) WithTime(t time.Time) *Entry
- type FieldMap
- type Fields
- type Formatter
- type Hook
- type InteractiveMigration
- type JSONFormatter
- type Level
- type LevelHooks
- type Logger
- func (logger *Logger) AddHook(hook Hook)
- func (logger *Logger) Debug(args ...interface{})
- func (logger *Logger) Debugf(format string, args ...interface{})
- func (logger *Logger) Debugln(args ...interface{})
- func (logger *Logger) Error(args ...interface{})
- func (logger *Logger) Errorf(format string, args ...interface{})
- func (logger *Logger) Errorln(args ...interface{})
- func (logger *Logger) Fatal(args ...interface{})
- func (logger *Logger) Fatalf(format string, args ...interface{})
- func (logger *Logger) Fatalln(args ...interface{})
- func (logger *Logger) GetLevel() Level
- func (logger *Logger) Info(args ...interface{})
- func (logger *Logger) Infof(format string, args ...interface{})
- func (logger *Logger) Infoln(args ...interface{})
- func (logger *Logger) IsLevelEnabled(level Level) bool
- func (logger *Logger) Log(level Level, args ...interface{})
- func (logger *Logger) Logf(level Level, format string, args ...interface{})
- func (logger *Logger) Logln(level Level, args ...interface{})
- func (logger *Logger) Panic(args ...interface{})
- func (logger *Logger) Panicf(format string, args ...interface{})
- func (logger *Logger) Panicln(args ...interface{})
- func (logger *Logger) Print(args ...interface{})
- func (logger *Logger) Printf(format string, args ...interface{})
- func (logger *Logger) Println(args ...interface{})
- func (logger *Logger) SetFormatter(formatter Formatter)
- func (logger *Logger) SetLevel(level Level)
- func (logger *Logger) SetOutput(output io.Writer)
- func (logger *Logger) Trace(args ...interface{})
- func (logger *Logger) Tracef(format string, args ...interface{})
- func (logger *Logger) Traceln(args ...interface{})
- func (logger *Logger) Warn(args ...interface{})
- func (logger *Logger) Warnf(format string, args ...interface{})
- func (logger *Logger) Warning(args ...interface{})
- func (logger *Logger) Warningf(format string, args ...interface{})
- func (logger *Logger) Warningln(args ...interface{})
- func (logger *Logger) Warnln(args ...interface{})
- func (logger *Logger) WithContext(ctx context.Context) *Entry
- func (logger *Logger) WithError(err error) *Entry
- func (logger *Logger) WithField(key string, value interface{}) *Entry
- func (logger *Logger) WithFields(fields Fields) *Entry
- func (logger *Logger) WithTime(t time.Time) *Entry
- type LogrusTransformer
- func (t *LogrusTransformer) GenerateMigrationReport(results []*TransformationResult, outputPath string) error
- func (t *LogrusTransformer) TransformDirectory(inputDir, outputDir string) ([]*TransformationResult, error)
- func (t *LogrusTransformer) TransformFile(inputPath, outputPath string) (*TransformationResult, error)
- func (t *LogrusTransformer) ValidateTransformation(inputPath, outputPath string) (*ValidationResult, error)
- type PerformanceComparisonResult
- type TextFormatter
- type TransformationResult
- type TransformationRule
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
var StandardLogger = New()
StandardLogger returns the standard logger.
Functions ¶
func BenchmarkBoltComplexStructure ¶
BenchmarkBoltComplexStructure benchmarks complex structured logging with Bolt.
func BenchmarkBoltErrorLogging ¶
BenchmarkBoltErrorLogging benchmarks Bolt error logging.
func BenchmarkBoltSimpleLogging ¶
BenchmarkBoltSimpleLogging benchmarks simple Bolt logging.
func BenchmarkBoltStructuredLogging ¶
BenchmarkBoltStructuredLogging benchmarks Bolt structured logging.
func BenchmarkBoltWithContext ¶
BenchmarkBoltWithContext benchmarks Bolt context logging.
func BenchmarkLogrusComplexStructure ¶
BenchmarkLogrusComplexStructure benchmarks complex structured logging with Logrus.
func BenchmarkLogrusErrorLogging ¶
BenchmarkLogrusErrorLogging benchmarks Logrus error logging.
func BenchmarkLogrusSimpleLogging ¶
BenchmarkLogrusSimpleLogging benchmarks simple Logrus logging.
func BenchmarkLogrusStructuredLogging ¶
BenchmarkLogrusStructuredLogging benchmarks Logrus structured logging.
func BenchmarkLogrusWithContext ¶
BenchmarkLogrusWithContext benchmarks Logrus context logging.
func ConcurrentLoggingBenchmark ¶
func ConcurrentLoggingBenchmark()
ConcurrentLoggingBenchmark demonstrates concurrent logging performance.
func ExampleBasicLogging ¶
func ExampleBasicLogging()
ExampleBasicLogging demonstrates basic logging migration from Logrus to Bolt.
func ExampleCompatibilityLayer ¶
func ExampleCompatibilityLayer()
ExampleCompatibilityLayer demonstrates using the compatibility layer for gradual migration.
func ExampleContextLogging ¶
func ExampleContextLogging()
ExampleContextLogging demonstrates context-based logging migration.
func ExampleErrorHandling ¶
func ExampleErrorHandling()
ExampleErrorHandling demonstrates error handling migration.
func ExampleFieldTypes ¶
func ExampleFieldTypes()
ExampleFieldTypes demonstrates various field types migration.
func ExampleFormatterMigration ¶
func ExampleFormatterMigration()
ExampleFormatterMigration demonstrates formatter migration strategies.
func ExampleFullMigrationWorkflow ¶
func ExampleFullMigrationWorkflow()
ExampleFullMigrationWorkflow demonstrates a complete migration workflow.
func ExampleHookMigration ¶
func ExampleHookMigration()
ExampleHookMigration demonstrates how to handle Logrus hooks migration.
func ExampleLevelBasedLogging ¶
func ExampleLevelBasedLogging()
ExampleLevelBasedLogging demonstrates different log levels.
func ExampleLoggerConfiguration ¶
func ExampleLoggerConfiguration()
ExampleLoggerConfiguration demonstrates logger configuration migration.
func ExampleMigrationSteps ¶
func ExampleMigrationSteps()
ExampleMigrationSteps demonstrates a step-by-step migration approach.
func ExamplePerformanceComparison ¶
func ExamplePerformanceComparison()
ExamplePerformanceComparison demonstrates the performance improvement when migrating.
func ExampleStructuredLogging ¶
func ExampleStructuredLogging()
ExampleStructuredLogging demonstrates structured logging patterns.
func IsLevelEnabled ¶
IsLevelEnabled checks if the standard logger will output a logging event.
func PrintPerformanceResults ¶
func PrintPerformanceResults(results []PerformanceComparisonResult)
PrintPerformanceResults prints performance comparison results in a readable format.
func SetFormatter ¶
func SetFormatter(formatter Formatter)
SetFormatter sets the standard logger formatter.
Types ¶
type BenchmarkReport ¶
type BenchmarkReport struct {
Timestamp string `json:"timestamp"`
Summary BenchmarkSummary `json:"summary"`
Comparisons []PerformanceComparisonResult `json:"comparisons"`
Conclusions []string `json:"conclusions"`
}
BenchmarkReport generates a detailed benchmark report.
func GenerateBenchmarkReport ¶
func GenerateBenchmarkReport() *BenchmarkReport
GenerateBenchmarkReport creates a comprehensive benchmark report.
type BenchmarkSummary ¶
type BenchmarkSummary struct {
TotalTests int `json:"total_tests"`
AverageSpeedImprovement float64 `json:"average_speed_improvement"`
AverageAllocImprovement float64 `json:"average_alloc_improvement"`
AverageMemoryImprovement float64 `json:"average_memory_improvement"`
MaxSpeedImprovement float64 `json:"max_speed_improvement"`
MinSpeedImprovement float64 `json:"min_speed_improvement"`
}
BenchmarkSummary provides overall summary statistics.
type CustomHandler ¶
type CustomHandler struct {
// contains filtered or unexported fields
}
CustomHandler demonstrates how to implement hook-like functionality in Bolt.
type Entry ¶
type Entry struct {
Logger *Logger
Data Fields
Time time.Time
Level Level
Caller *runtime.Frame
Message string
Buffer []byte
Context context.Context
// contains filtered or unexported fields
}
Entry represents a log entry.
func WithContext ¶
WithContext creates an entry from the standard logger with a context.
func WithFields ¶
WithFields creates an entry from the standard logger and adds multiple fields to it.
func (*Entry) Debug ¶
func (entry *Entry) Debug(args ...interface{})
Debug logs a message at debug level.
func (*Entry) Debugln ¶
func (entry *Entry) Debugln(args ...interface{})
Debugln logs a message at debug level.
func (*Entry) Error ¶
func (entry *Entry) Error(args ...interface{})
Error logs a message at error level.
func (*Entry) Errorln ¶
func (entry *Entry) Errorln(args ...interface{})
Errorln logs a message at error level.
func (*Entry) Fatal ¶
func (entry *Entry) Fatal(args ...interface{})
Fatal logs a message at fatal level and calls os.Exit(1).
func (*Entry) Fatalln ¶
func (entry *Entry) Fatalln(args ...interface{})
Fatalln logs a message at fatal level and calls os.Exit(1).
func (*Entry) Info ¶
func (entry *Entry) Info(args ...interface{})
Info logs a message at info level.
func (*Entry) Infoln ¶
func (entry *Entry) Infoln(args ...interface{})
Infoln logs a message at info level.
func (*Entry) Panic ¶
func (entry *Entry) Panic(args ...interface{})
Panic logs a message at panic level and panics.
func (*Entry) Panicln ¶
func (entry *Entry) Panicln(args ...interface{})
Panicln logs a message at panic level and panics.
func (*Entry) Print ¶
func (entry *Entry) Print(args ...interface{})
Print logs a message at info level.
func (*Entry) Println ¶
func (entry *Entry) Println(args ...interface{})
Println logs a message at info level.
func (*Entry) String ¶
String returns the string representation from the reader and ultimately the formatter.
func (*Entry) Trace ¶
func (entry *Entry) Trace(args ...interface{})
Trace logs a message at trace level.
func (*Entry) Traceln ¶
func (entry *Entry) Traceln(args ...interface{})
Traceln logs a message at trace level.
func (*Entry) Warn ¶
func (entry *Entry) Warn(args ...interface{})
Warn logs a message at warn level.
func (*Entry) Warning ¶
func (entry *Entry) Warning(args ...interface{})
Warning logs a message at warn level.
func (*Entry) Warningln ¶
func (entry *Entry) Warningln(args ...interface{})
Warningln logs a message at warn level.
func (*Entry) Warnln ¶
func (entry *Entry) Warnln(args ...interface{})
Warnln logs a message at warn level.
func (*Entry) WithContext ¶
WithContext adds a context to the Entry.
func (*Entry) WithFields ¶
WithFields adds a map of fields to the Entry.
type InteractiveMigration ¶
type InteractiveMigration struct {
// contains filtered or unexported fields
}
InteractiveMigration provides an interactive migration experience.
func NewInteractiveMigration ¶
func NewInteractiveMigration(input io.Reader, output io.Writer) *InteractiveMigration
NewInteractiveMigration creates a new interactive migration helper.
func (*InteractiveMigration) RunInteractive ¶
func (im *InteractiveMigration) RunInteractive() error
RunInteractive runs an interactive migration session.
type JSONFormatter ¶
type JSONFormatter struct {
TimestampFormat string
DisableTimestamp bool
DisableHTMLEscape bool
DataKey string
FieldMap FieldMap
CallerPrettyfier func(*runtime.Frame) (function string, file string)
PrettyPrint bool
}
JSONFormatter formats logs into parsable json.
type Level ¶
type Level uint32
Level defines logging levels compatible with Logrus.
const ( // PanicLevel level, highest level of severity. PanicLevel Level = iota // FatalLevel level. Logs and then calls `os.Exit(1)`. FatalLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. ErrorLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // InfoLevel level. General operational entries about what's happening inside the application. InfoLevel // DebugLevel level. Usually only enabled when debugging. DebugLevel // TraceLevel level. Designates finer-grained informational events than the Debug. TraceLevel )
func ParseLevel ¶
ParseLevel converts a string to a Level.
type LevelHooks ¶
LevelHooks is a map of hooks for each level.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides a Logrus-compatible API backed by Bolt for easier migration.
func (*Logger) IsLevelEnabled ¶
IsLevelEnabled checks if the logger will output a logging event.
func (*Logger) SetFormatter ¶
SetFormatter sets the logger formatter.
func (*Logger) Trace ¶
func (logger *Logger) Trace(args ...interface{})
Logging methods for each level
func (*Logger) WithContext ¶
WithContext creates an entry with a context.
func (*Logger) WithFields ¶
WithFields creates an entry with multiple fields.
type LogrusTransformer ¶
type LogrusTransformer struct {
// contains filtered or unexported fields
}
LogrusTransformer handles the transformation of Logrus code to Bolt.
func NewLogrusTransformer ¶
func NewLogrusTransformer() *LogrusTransformer
NewLogrusTransformer creates a new transformer for Logrus to Bolt migration.
func (*LogrusTransformer) GenerateMigrationReport ¶
func (t *LogrusTransformer) GenerateMigrationReport(results []*TransformationResult, outputPath string) error
GenerateMigrationReport generates a comprehensive migration report.
func (*LogrusTransformer) TransformDirectory ¶
func (t *LogrusTransformer) TransformDirectory(inputDir, outputDir string) ([]*TransformationResult, error)
TransformDirectory transforms all Go files in a directory.
func (*LogrusTransformer) TransformFile ¶
func (t *LogrusTransformer) TransformFile(inputPath, outputPath string) (*TransformationResult, error)
TransformFile transforms a single file from Logrus to Bolt.
func (*LogrusTransformer) ValidateTransformation ¶
func (t *LogrusTransformer) ValidateTransformation(inputPath, outputPath string) (*ValidationResult, error)
ValidateTransformation validates that the transformation was successful.
type PerformanceComparisonResult ¶
type PerformanceComparisonResult struct {
TestName string `json:"test_name"`
LogrusNsPerOp int64 `json:"logrus_ns_per_op"`
BoltNsPerOp int64 `json:"bolt_ns_per_op"`
LogrusAllocsPerOp int64 `json:"logrus_allocs_per_op"`
BoltAllocsPerOp int64 `json:"bolt_allocs_per_op"`
LogrusBytesPerOp int64 `json:"logrus_bytes_per_op"`
BoltBytesPerOp int64 `json:"bolt_bytes_per_op"`
SpeedImprovement float64 `json:"speed_improvement_percent"`
AllocImprovement float64 `json:"alloc_improvement_percent"`
MemoryImprovement float64 `json:"memory_improvement_percent"`
}
PerformanceComparisonResult holds the results of a performance comparison.
func RunPerformanceComparison ¶
func RunPerformanceComparison() []PerformanceComparisonResult
RunPerformanceComparison runs a comprehensive performance comparison between Logrus and Bolt.
type TextFormatter ¶
type TextFormatter struct {
ForceColors bool
DisableColors bool
ForceQuote bool
DisableQuote bool
EnvironmentOverrideColors bool
DisableTimestamp bool
FullTimestamp bool
TimestampFormat string
DisableSorting bool
SortingFunc func([]string)
DisableLevelTruncation bool
PadLevelText bool
QuoteEmptyFields bool
CallerPrettyfier func(*runtime.Frame) (function string, file string)
}
TextFormatter formats logs into text.
type TransformationResult ¶
type TransformationResult struct {
OriginalFile string `json:"original_file"`
TransformedFile string `json:"transformed_file"`
AppliedRules []string `json:"applied_rules"`
Errors []string `json:"errors"`
Warnings []string `json:"warnings"`
LineChanges map[int]string `json:"line_changes"`
Success bool `json:"success"`
}
TransformationResult represents the result of a transformation operation.
type TransformationRule ¶
type TransformationRule struct {
Name string
Description string
Pattern *regexp.Regexp
Replace string
IsRegex bool
}
TransformationRule represents a rule for transforming Logrus code to Bolt.
type ValidationResult ¶
type ValidationResult struct {
Success bool `json:"success"`
Errors []string `json:"errors"`
Warnings []string `json:"warnings"`
}
ValidationResult represents validation results.