// Package hlog provides a structured logging solution built on top of zerolog. // // hlog supports multiple output modes (console, file, or both), configurable // log levels, and automatic log file management. It is designed to be simple // to configure via environment variables while remaining flexible for // programmatic configuration. // // # Basic Usage // // Create a logger with environment-based configuration: // // cfg, err := hlog.ConfigFromEnv() // if err != nil { // log.Fatal(err) // } // // logger, err := hlog.NewLogger(cfg, os.Stdout) // if err != nil { // log.Fatal(err) // } // defer logger.CloseLogFile() // // logger.Info().Msg("Application started") // // # Configuration // // hlog can be configured via environment variables: // // LOG_LEVEL=info # trace, debug, info, warn, error, fatal, panic (default: info) // LOG_OUTPUT=console # console, file, or both (default: console) // LOG_DIR=/var/log/app # Required when LOG_OUTPUT is "file" or "both" // // Or programmatically: // // cfg := &hlog.Config{ // LogLevel: hlog.InfoLevel, // LogOutput: "both", // LogDir: "/var/log/myapp", // } // // # Log Levels // // hlog supports the following log levels (from most to least verbose): // - trace: Very detailed debugging information // - debug: Detailed debugging information // - info: General informational messages // - warn: Warning messages for potentially harmful situations // - error: Error messages for error events // - fatal: Fatal messages that will exit the application // - panic: Panic messages that will panic the application // // # Output Modes // // - console: Logs to the provided io.Writer (typically os.Stdout or os.Stderr) // - file: Logs to a file named "server.log" in the configured directory // - both: Logs to both console and file simultaneously // // # File Management // // When using file output, hlog creates a file named "server.log" in the // specified directory. The file is opened in append mode, so logs persist // across application restarts. Remember to call CloseLogFile() when shutting // down your application to ensure all logs are flushed. package hlog