API Reference
The DD logging library provides a rich set of APIs, organized by functional modules:
Core Components
| Module | Description | Documentation |
|---|---|---|
| Package Functions | Global logging functions, convenience constructors | Package Functions |
| Logger | Core logger and its methods | Logger |
| LoggerEntry | Log Entry with preset fields | LoggerEntry |
| Config | Configuration struct and presets | Configuration |
| Interfaces | CoreLogger, LogProvider and other interfaces | Interface Definitions |
Output and Writing
| Module | Description | Documentation |
|---|---|---|
| Writers | FileWriter, BufferedWriter, MultiWriter | Output Targets |
| Context | Context integration and ContextExtractor | Context Integration |
Extended Features
| Module | Description | Documentation |
|---|---|---|
| Fields | Structured field constructors (20+ types) | Structured Fields |
| Hooks | Lifecycle hook system | Hook System |
| Security | Sensitive data filtering and security config | Security Filtering |
| Audit | Audit logging and audit events | Audit Logging |
| Integrity | Log integrity signing and verification | Integrity Signing |
Utility Tools
| Module | Description | Documentation |
|---|---|---|
| Debug Visual | Print/JSON/Text/Exit debug functions | Debug Output |
| Recorder | Testing helper log recorder | Testing Helper |
| Constants | Log levels, formats, error codes | Constants and Errors |
Quick Reference
go
// Basic usage
dd.Info("message") // → Package Functions
dd.InfoWith("msg", dd.String("k", "v")) // → Package Functions + Fields
// Create a custom logger
logger, _ := dd.New(dd.DefaultConfig()) // → Package Functions + Config
logger.WithFields(fields).Info("msg") // → Logger + Entry
// File output
fw, _ := dd.NewFileWriter("logs/app.log", dd.DefaultFileWriterConfig()) // → Writers
// Security
sec := dd.DefaultSecurityConfig() // → Security
audit, _ := dd.NewAuditLogger(dd.DefaultAuditConfig()) // → AuditNext Steps
- Package Functions -- Global functions and constructors
- Logger -- Core logger in detail
- Configuration -- Configuration options