Skip to content

DD ​

DD (read as "data-driven" or "distributed debugger" in the source comments) is a high-performance structured logging library from the CyberGo organization, providing thread-safe log recording, flexible output target configuration, and comprehensive security protection.

Features ​

  • Structured Logging -- Type-safe field recording with optional JSON output
  • Multiple Output Targets -- Simultaneous output to console, file, and custom io.Writer
  • File Rotation -- Automatic size-based rotation with configurable backup count and retention policies
  • Sensitive Data Filtering -- Built-in regex patterns for automatic redaction of passwords, keys, tokens, and other sensitive information
  • Field Validation -- Field key naming convention validation (snake_case/camelCase, etc.) with Log4Shell injection protection
  • Audit Logging -- Asynchronous audit event recording with HMAC integrity signing and sequence numbers
  • Hook System -- Lifecycle hooks including BeforeLog, AfterLog, OnRotate, and more
  • Context Integration -- Provides TraceID/SpanID/RequestID context utilities and a ContextExtractor extension point (logging methods do not accept ctx; pass fields via WithFields)
  • Log Sampling -- Optional log sampling strategy for high-throughput scenarios
  • Low-Allocation Optimization -- Minimized memory allocation on hot paths for exceptional performance

Installation ​

bash
go get github.com/cybergodev/dd

Quick Start ​

go
package main

import (
	"time"

	"github.com/cybergodev/dd"
)

func main() {
	// Use the default logger
	dd.Info("service started")

	// Structured logging
	dd.InfoWith("request completed",
		dd.String("method", "GET"),
		dd.Int("status", 200),
		dd.Duration("elapsed", 150*time.Millisecond),
	)

	// Create a custom logger
	logger, _ := dd.New(dd.DefaultConfig())
	defer logger.Close()

	logger.Info("custom logger created")
}

Module Navigation ​

ModuleDescription
Core ConceptsLogger hierarchy, processing pipeline, interface levels
ConfigurationConfig struct, presets, output targets
Structured LoggingField constructors, method chaining
File Output & RotationFileWriter, BufferedWriter
Log SamplingHigh-throughput log volume reduction
Hook SystemLifecycle hook extensions
Error HandlingStructured errors, sentinel errors, errors.Is
Sensitive Data FilteringAuto-redaction, security levels
Field ValidationNaming convention checks, Log4Shell protection
Audit LoggingAsynchronous audit events, integrity signing
Distributed TracingTraceID/SpanID/RequestID
Migration GuideMigrate from log/slog/zap/logrus

Next Steps ​