Documentation
¶
Overview ¶
Package stdlog provides benchmarking tools for comparing standard log and Bolt performance.
Package stdlog provides compatibility layer and migration tools for Go standard log users.
Package stdlog provides examples demonstrating migration from Go's standard log to Bolt.
Package stdlog provides code transformation tools for migrating from standard log to Bolt.
Index ¶
- Constants
- func BenchmarkBoltComplexStructured(b *testing.B)
- func BenchmarkBoltContextualLogger(b *testing.B)
- func BenchmarkBoltSimpleLogging(b *testing.B)
- func BenchmarkBoltStructuredLogging(b *testing.B)
- func BenchmarkBoltWithCallerInfo(b *testing.B)
- func BenchmarkStandardLogCompatibility(b *testing.B)
- func BenchmarkStandardLogComplexFormatting(b *testing.B)
- func BenchmarkStandardLogCustomLogger(b *testing.B)
- func BenchmarkStandardLogPrint(b *testing.B)
- func BenchmarkStandardLogPrintf(b *testing.B)
- func BenchmarkStandardLogWithCallerInfo(b *testing.B)
- func ConcurrentBenchmark()
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func EnableStructuredLogging() *bolt.Logger
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func ExampleAdvancedFeatures()
- func ExampleBasicMigration()
- func ExampleConfigurationMigration()
- func ExampleCustomLogger()
- func ExampleDropInReplacement()
- func ExampleErrorHandling()
- func ExampleGradualMigration()
- func ExampleLogLevels()
- func ExampleMigrationBestPractices()
- func ExampleMigrationStrategies()
- func ExampleOutputFormats()
- func ExamplePerformanceComparison()
- func ExamplePerformanceTesting()
- func ExampleRealWorldMigration()
- func ExampleStructuredLogging()
- func ExampleTestingMigration()
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Fatalln(v ...interface{})
- func Flags() int
- func GetUnderlyingLogger() *bolt.Logger
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func MemoryProfileComparison()
- func MigrateStandardLogger(output io.Writer, prefix string, flag int)
- func Output(calldepth int, s string) error
- func Panic(v ...interface{})
- func Panicf(format string, v ...interface{})
- func Panicln(v ...interface{})
- func Prefix() string
- func Print(v ...interface{})
- func PrintMigrationImpactReport(reports []MigrationImpactReport)
- func PrintPerformanceReport(metrics []PerformanceMetrics)
- func Printf(format string, v ...interface{})
- func Println(v ...interface{})
- func SetFlags(flag int)
- func SetLevel(level string)
- func SetOutput(w io.Writer)
- func SetPrefix(prefix string)
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- func Writer() io.Writer
- type BenchmarkReport
- type BenchmarkSummary
- type InteractiveMigration
- type Logger
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Fatalln(v ...interface{})
- func (l *Logger) Flags() int
- func (l *Logger) Output(calldepth int, s string) error
- func (l *Logger) Panic(v ...interface{})
- func (l *Logger) Panicf(format string, v ...interface{})
- func (l *Logger) Panicln(v ...interface{})
- func (l *Logger) Prefix() string
- func (l *Logger) Print(v ...interface{})
- func (l *Logger) Printf(format string, v ...interface{})
- func (l *Logger) Println(v ...interface{})
- func (l *Logger) SetFlags(flag int)
- func (l *Logger) SetOutput(w io.Writer)
- func (l *Logger) SetPrefix(prefix string)
- func (l *Logger) Writer() io.Writer
- type MigrationImpactReport
- type PerformanceMetrics
- type StdlogTransformer
- func (t *StdlogTransformer) GenerateMigrationGuide(results []*TransformationResult, outputPath string) error
- func (t *StdlogTransformer) TransformDirectory(inputDir, outputDir string) ([]*TransformationResult, error)
- func (t *StdlogTransformer) TransformFile(inputPath, outputPath string) (*TransformationResult, error)
- type TransformationResult
- type TransformationRule
Constants ¶
const ( Ldate = 1 << iota // the date in the local time zone Ltime // the time in the local time zone Lmicroseconds // microsecond resolution Llongfile // full file name and line number Lshortfile // final file name element and line number LUTC // use UTC rather than the local time zone Lmsgprefix // move the "prefix" from the beginning of the line to before the message LstdFlags = Ldate | Ltime // initial values for the standard logger )
Log flag constants - compatible with standard library log package.
Variables ¶
This section is empty.
Functions ¶
func BenchmarkBoltComplexStructured ¶
BenchmarkBoltComplexStructured benchmarks equivalent complex structured logging.
func BenchmarkBoltContextualLogger ¶
BenchmarkBoltContextualLogger benchmarks Bolt with contextual logging.
func BenchmarkBoltSimpleLogging ¶
BenchmarkBoltSimpleLogging benchmarks equivalent Bolt logging.
func BenchmarkBoltStructuredLogging ¶
BenchmarkBoltStructuredLogging benchmarks equivalent structured Bolt logging.
func BenchmarkBoltWithCallerInfo ¶
BenchmarkBoltWithCallerInfo benchmarks Bolt logging with caller info.
func BenchmarkStandardLogCompatibility ¶
BenchmarkStandardLogCompatibility benchmarks the compatibility layer.
func BenchmarkStandardLogComplexFormatting ¶
BenchmarkStandardLogComplexFormatting benchmarks complex string formatting.
func BenchmarkStandardLogCustomLogger ¶
BenchmarkStandardLogCustomLogger benchmarks custom logger usage.
func BenchmarkStandardLogPrint ¶
BenchmarkStandardLogPrint benchmarks standard library log.Print.
func BenchmarkStandardLogPrintf ¶
BenchmarkStandardLogPrintf benchmarks standard library log.Printf.
func BenchmarkStandardLogWithCallerInfo ¶
BenchmarkStandardLogWithCallerInfo benchmarks standard log with caller info.
func ConcurrentBenchmark ¶
func ConcurrentBenchmark()
ConcurrentBenchmark demonstrates concurrent logging performance.
func Debug ¶
func Debug(v ...interface{})
Debug provides debug-level logging (not in standard log, but commonly needed).
func Debugf ¶
func Debugf(format string, v ...interface{})
Debugf provides formatted debug-level logging.
func EnableStructuredLogging ¶
EnableStructuredLogging enables structured logging features while maintaining compatibility. This allows gradual migration to structured logging patterns.
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf provides formatted error-level logging.
func ExampleAdvancedFeatures ¶
func ExampleAdvancedFeatures()
ExampleAdvancedFeatures demonstrates advanced Bolt features not available in standard log.
func ExampleBasicMigration ¶
func ExampleBasicMigration()
ExampleBasicMigration demonstrates basic logging migration from standard log to Bolt.
func ExampleConfigurationMigration ¶
func ExampleConfigurationMigration()
ExampleConfigurationMigration demonstrates configuration migration patterns.
func ExampleCustomLogger ¶
func ExampleCustomLogger()
ExampleCustomLogger demonstrates custom logger migration.
func ExampleDropInReplacement ¶
func ExampleDropInReplacement()
ExampleDropInReplacement demonstrates the drop-in replacement approach.
func ExampleErrorHandling ¶
func ExampleErrorHandling()
ExampleErrorHandling demonstrates error and panic handling migration.
func ExampleGradualMigration ¶
func ExampleGradualMigration()
ExampleGradualMigration demonstrates a step-by-step migration approach.
func ExampleLogLevels ¶
func ExampleLogLevels()
ExampleLogLevels demonstrates migrating from print statements to proper levels.
func ExampleMigrationBestPractices ¶
func ExampleMigrationBestPractices()
ExampleMigrationBestPractices demonstrates best practices during and after migration.
func ExampleMigrationStrategies ¶
func ExampleMigrationStrategies()
ExampleMigrationStrategies demonstrates different migration approaches.
func ExampleOutputFormats ¶
func ExampleOutputFormats()
ExampleOutputFormats demonstrates different output format options.
func ExamplePerformanceComparison ¶
func ExamplePerformanceComparison()
ExamplePerformanceComparison demonstrates performance benefits.
func ExamplePerformanceTesting ¶
func ExamplePerformanceTesting()
ExamplePerformanceTesting demonstrates how to measure migration benefits.
func ExampleRealWorldMigration ¶
func ExampleRealWorldMigration()
ExampleRealWorldMigration demonstrates a complete real-world migration scenario.
func ExampleStructuredLogging ¶
func ExampleStructuredLogging()
ExampleStructuredLogging demonstrates the evolution from string formatting to structured fields.
func ExampleTestingMigration ¶
func ExampleTestingMigration()
ExampleTestingMigration demonstrates testing considerations during migration.
func Fatal ¶
func Fatal(v ...interface{})
Fatal is equivalent to Print() followed by a call to os.Exit(1).
func Fatalf ¶
func Fatalf(format string, v ...interface{})
Fatalf is equivalent to Printf() followed by a call to os.Exit(1).
func Fatalln ¶
func Fatalln(v ...interface{})
Fatalln is equivalent to Println() followed by a call to os.Exit(1).
func GetUnderlyingLogger ¶
GetUnderlyingLogger returns the underlying Bolt logger for advanced usage. This allows access to Bolt's structured logging features while maintaining standard log compatibility for the rest of the application.
func Info ¶
func Info(v ...interface{})
Info provides info-level logging (alias for Print functions).
func Infof ¶
func Infof(format string, v ...interface{})
Infof provides formatted info-level logging (alias for Printf).
func MemoryProfileComparison ¶
func MemoryProfileComparison()
MemoryProfileComparison demonstrates memory usage patterns.
func MigrateStandardLogger ¶
MigrateStandardLogger replaces the global standard logger with a Bolt-backed version. This is useful for applications that use the global log functions.
func Output ¶
Output writes the output for a logging event. The string s contains the text to print; a newline character will be added if one is not provided. Calldepth is used to recover the PC and is provided for generality, although at the moment on all pre-defined paths it will be 2.
func Panic ¶
func Panic(v ...interface{})
Panic is equivalent to Print() followed by a call to panic().
func Panicf ¶
func Panicf(format string, v ...interface{})
Panicf is equivalent to Printf() followed by a call to panic().
func Panicln ¶
func Panicln(v ...interface{})
Panicln is equivalent to Println() followed by a call to panic().
func PrintMigrationImpactReport ¶
func PrintMigrationImpactReport(reports []MigrationImpactReport)
PrintMigrationImpactReport prints the business impact of migration.
func PrintPerformanceReport ¶
func PrintPerformanceReport(metrics []PerformanceMetrics)
PrintPerformanceReport prints a detailed performance comparison report.
func Printf ¶
func Printf(format string, v ...interface{})
Printf calls Output to print to the standard logger.
func SetLevel ¶
func SetLevel(level string)
SetLevel sets the logging level for the underlying Bolt logger. This provides level-based filtering not available in standard log.
func SetPrefix ¶
func SetPrefix(prefix string)
SetPrefix sets the output prefix for the standard logger.
Types ¶
type BenchmarkReport ¶
type BenchmarkReport struct {
Timestamp string `json:"timestamp"`
Summary BenchmarkSummary `json:"summary"`
PerformanceTests []PerformanceMetrics `json:"performance_tests"`
ImpactAnalysis []MigrationImpactReport `json:"impact_analysis"`
Recommendations []string `json:"recommendations"`
}
BenchmarkReport provides a comprehensive benchmark report.
func GenerateComprehensiveBenchmarkReport ¶
func GenerateComprehensiveBenchmarkReport() *BenchmarkReport
GenerateComprehensiveBenchmarkReport creates a full benchmark report.
type BenchmarkSummary ¶
type BenchmarkSummary struct {
TotalTests int `json:"total_tests"`
AverageSpeedImprovement float64 `json:"average_speed_improvement"`
AverageAllocReduction float64 `json:"average_alloc_reduction"`
AverageMemoryReduction float64 `json:"average_memory_reduction"`
MaxSpeedImprovement float64 `json:"max_speed_improvement"`
MinSpeedImprovement float64 `json:"min_speed_improvement"`
RecommendedMigration string `json:"recommended_migration"`
}
BenchmarkSummary provides overall benchmark statistics.
type InteractiveMigration ¶
type InteractiveMigration struct {
// contains filtered or unexported fields
}
InteractiveMigration provides interactive migration for standard log.
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 Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides a drop-in replacement for Go's standard log.Logger. This allows existing code using the standard library to benefit from Bolt's performance while maintaining full API compatibility.
func CreateCompatibleLogger ¶
CreateCompatibleLogger creates a logger that's compatible with existing standard log usage but provides the performance benefits of Bolt.
func Default ¶
func Default() *Logger
Default creates a standard logger that writes to stderr with default flags.
func New ¶
New creates a new Logger that's compatible with Go's standard log.Logger. The out parameter is the destination to which log data will be written. The prefix appears at the beginning of each generated log line, or after the log header if Lmsgprefix flag is provided. The flag argument defines the logging properties.
func (*Logger) Fatal ¶
func (l *Logger) Fatal(v ...interface{})
Fatal is equivalent to Print() followed by a call to os.Exit(1).
func (*Logger) Fatalln ¶
func (l *Logger) Fatalln(v ...interface{})
Fatalln is equivalent to Println() followed by a call to os.Exit(1).
func (*Logger) Output ¶
Output writes the output for a logging event. The calldepth parameter is ignored as Bolt handles caller information automatically.
func (*Logger) Panic ¶
func (l *Logger) Panic(v ...interface{})
Panic is equivalent to Print() followed by a call to panic().
func (*Logger) Panicln ¶
func (l *Logger) Panicln(v ...interface{})
Panicln is equivalent to Println() followed by a call to panic().
func (*Logger) Print ¶
func (l *Logger) Print(v ...interface{})
Print calls l.Output to print to the logger.
func (*Logger) Println ¶
func (l *Logger) Println(v ...interface{})
Println calls l.Output to print to the logger.
type MigrationImpactReport ¶
type MigrationImpactReport struct {
ApplicationScenario string `json:"application_scenario"`
LogsPerSecond int `json:"logs_per_second"`
StandardLogLatency float64 `json:"standard_log_latency_ns"`
BoltLatency float64 `json:"bolt_latency_ns"`
LatencyReduction float64 `json:"latency_reduction_percent"`
ThroughputImprovement float64 `json:"throughput_improvement_percent"`
MemoryReduction float64 `json:"memory_reduction_percent"`
CPUReduction float64 `json:"cpu_reduction_percent"`
}
MigrationImpactReport demonstrates the business impact of migration.
func GenerateMigrationImpactReport ¶
func GenerateMigrationImpactReport() []MigrationImpactReport
GenerateMigrationImpactReport creates impact reports for different scenarios.
type PerformanceMetrics ¶
type PerformanceMetrics struct {
TestName string `json:"test_name"`
StandardLogNsPerOp int64 `json:"standard_log_ns_per_op"`
BoltNsPerOp int64 `json:"bolt_ns_per_op"`
StandardLogAllocsPerOp int64 `json:"standard_log_allocs_per_op"`
BoltAllocsPerOp int64 `json:"bolt_allocs_per_op"`
StandardLogBytesPerOp int64 `json:"standard_log_bytes_per_op"`
BoltBytesPerOp int64 `json:"bolt_bytes_per_op"`
SpeedImprovementPercent float64 `json:"speed_improvement_percent"`
AllocReductionPercent float64 `json:"alloc_reduction_percent"`
MemoryReductionPercent float64 `json:"memory_reduction_percent"`
}
PerformanceMetrics holds performance comparison results.
func RunPerformanceComparison ¶
func RunPerformanceComparison() []PerformanceMetrics
RunPerformanceComparison runs a comprehensive performance comparison.
type StdlogTransformer ¶
type StdlogTransformer struct {
// contains filtered or unexported fields
}
StdlogTransformer handles the transformation of standard log code to Bolt.
func NewStdlogTransformer ¶
func NewStdlogTransformer() *StdlogTransformer
NewStdlogTransformer creates a new transformer for standard log to Bolt migration.
func (*StdlogTransformer) GenerateMigrationGuide ¶
func (t *StdlogTransformer) GenerateMigrationGuide(results []*TransformationResult, outputPath string) error
GenerateMigrationGuide generates a comprehensive migration guide.
func (*StdlogTransformer) TransformDirectory ¶
func (t *StdlogTransformer) TransformDirectory(inputDir, outputDir string) ([]*TransformationResult, error)
TransformDirectory transforms all Go files in a directory.
func (*StdlogTransformer) TransformFile ¶
func (t *StdlogTransformer) TransformFile(inputPath, outputPath string) (*TransformationResult, error)
TransformFile transforms a single file from standard log to Bolt.
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"`
RequiresManual []string `json:"requires_manual"`
}
TransformationResult represents the result of a transformation operation.