ion

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 17 Imported by: 0

README

Ion

Ion is an enterprise-grade, structured logging library designed for high-performance blockchain applications at JupiterMeta Labs.

It combines the raw speed of Zap with seamless OpenTelemetry (OTEL) integration, ensuring your logs are both fast and observable.

Features

  • 🚀 High Performance: Built on Uber's Zap with pool-optimized, low-allocation hot paths.
  • 🔭 OpenTelemetry Native: Seamless integration with OTEL for distributed tracing (Logs + Traces).
  • 🛡️ Enterprise Grade: Reliable Shutdown hooks, internal pooling, and safe concurrency patterns.
  • 🔗 Blockchain Ready: Specialized field helpers for TxHash, Slot, ShardID, and more.
  • 📝 Developer Friendly: Pretty console output for local dev, JSON for production.
  • 🔄 Lumberjack: Built-in file rotation and compression.

Installation

go get github.com/JupiterMetaLabs/ion@latest

Quick Start

package main

import (
    "context"
    
    "github.com/JupiterMetaLabs/ion"
)

func main() {
    ctx := context.Background()

    // Configure from environment variables
    ion.SetGlobal(ion.InitFromEnv())
    defer ion.Sync()

    ion.Info(ctx, "application started")
    RunServer(ctx)
}

func RunServer(ctx context.Context) {
    ion.Info(ctx, "server listening", ion.Int("port", 8080))
}
type Server struct {
    logger ion.Logger
}

func NewServer(l ion.Logger) *Server {
    return &Server{logger: l.Named("server")}
}

func (s *Server) Start(ctx context.Context) {
    s.logger.Info(ctx, "server started")
}

Core Concepts

Child Loggers (With and Named)

Create scoped loggers that inherit configuration but add specific context:

  • With: Adds permanent fields to every log entry.
  • Named: Adds a "logger" name (component identifier).
dbLogger := logger.Named("db").With(ion.String("db_name", "orders"))

dbLogger.Info(ctx, "connection established") 
// Output: {"level":"info", "logger":"db", "db_name":"orders", "msg":"..."}
Context Integration

Context is always the first parameter. Trace IDs are extracted automatically:

func HandleRequest(ctx context.Context) {
    // trace_id and span_id are extracted from ctx automatically
    logger.Info(ctx, "processing request", ion.String("endpoint", "/api/orders"))
}

// For startup/shutdown (no trace):
ion.Info(context.Background(), "service starting")

Configuration

Ion uses a strongly typed Config struct:

cfg := ion.Default()
cfg.Level = "debug"
cfg.ServiceName = "payment-service"
cfg.OTEL.Enabled = true
cfg.OTEL.Endpoint = "otel-collector:4317"

logger := ion.New(cfg)
Production Configuration
cfg := ion.Config{
    Level:       "info",
    Development: false,
    ServiceName: "payment-service",
    Version:     "1.2.0",
    
    // File Logging with Rotation
    File: ion.FileConfig{
        Enabled:    true,
        Path:       "/var/log/app/service.log",
        MaxSizeMB:  100,
        MaxBackups: 10,
        MaxAgeDays: 7,
        Compress:   true,
    },

    // OpenTelemetry Export
    OTEL: ion.OTELConfig{
        Enabled:  true,
        Endpoint: "otel-collector:4317",
        Protocol: "grpc",
        Insecure: false,
        Username: "admin",        // Basic Auth (optional)
        Password: "supersecret",  // Basic Auth (optional)
        Attributes: map[string]string{
            "env": "production",
        },
    },
}
logger, _ := ion.NewWithOTEL(cfg)
defer logger.Shutdown(ctx)

Environment Variables

InitFromEnv() reads the following environment variables for zero-code configuration:

Variable Default Description
LOG_LEVEL info Minimum log level: debug, info, warn, error
LOG_DEVELOPMENT false Set to true for pretty console output
SERVICE_NAME unknown Service name for logs and OTEL
SERVICE_VERSION "" Service version for OTEL resources
OTEL_ENDPOINT "" OTEL collector address (enables OTEL if set)
OTEL_INSECURE false Set to true to disable TLS
OTEL_USERNAME "" Basic Auth username
OTEL_PASSWORD "" Basic Auth password

Example deployment:

export LOG_LEVEL=info
export SERVICE_NAME=payment-service
export OTEL_ENDPOINT=otel-collector:4317
export OTEL_USERNAME=admin
export OTEL_PASSWORD=secret

./my-service

Configuration Reference

Core Settings
Field Type Default Description
level string info Minimum log level
development bool false Pretty printing + caller info
service_name string unknown Service identifier
version string "" Service version
Console Configuration
Field Type Default Description
console.enabled bool true Enable stdout/stderr output
console.format string json json or pretty
console.color bool true ANSI colors in pretty mode
console.errors_to_stderr bool true Send warn/error to stderr
File Configuration
Field Type Default Description
file.enabled bool false Enable file logging
file.path string "" Log file path
file.max_size_mb int 100 Max size before rotation (MB)
file.max_age_days int 7 Max days to keep old logs
file.max_backups int 5 Max rotated files to keep
file.compress bool true Gzip rotated files
OTEL Configuration
Field Type Default Description
otel.enabled bool false Enable OTEL export
otel.endpoint string "" Collector address
otel.protocol string grpc grpc or http
otel.insecure bool false Disable TLS
otel.username string "" Basic Auth username
otel.password string "" Basic Auth password
otel.headers map {} Additional headers
otel.timeout duration 10s Export timeout
otel.batch_size int 512 Logs per batch
otel.export_interval duration 5s Batch flush interval
otel.attributes map {} Resource attributes

Usage Patterns for Teams

1. Dependency Injection (Preferred)

Pass ion.Logger explicitly to components. This makes testing easier and dependencies clear.

type Server struct {
    log ion.Logger
}

func NewServer(l ion.Logger) *Server {
    return &Server{
        log: l.Named("server").With(ion.String("component", "http")),
    }
}
2. Global Singleton (Legacy/Scripts)

For existing codebases or simple scripts where DI is impractical:

// In main.go
ion.SetGlobal(logger)

// In any package
func DoWork(ctx context.Context) {
    ion.L().Info(ctx, "doing work")
}
3. Hot Reloading Pattern

Start with a basic logger, then upgrade after loading configuration:

func main() {
    ctx := context.Background()

    // 1. Start with safe defaults
    ion.SetGlobal(ion.New(ion.Default()))

    // 2. Load configuration
    appConfig := LoadConfig()

    // 3. Initialize production logger
    prodLogger, err := ion.NewWithOTEL(appConfig.Log)
    if err != nil {
        ion.Fatal(ctx, "failed to init logger", err)
    }

    // 4. Replace global logger
    ion.SetGlobal(prodLogger)
    defer prodLogger.Shutdown(ctx)
    
    // 5. Run application
    RunApp(ctx)
}

Lifecycle Management

Graceful Shutdown

Always flush before exit to prevent data loss:

logger, _ := ion.NewWithOTEL(cfg)

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
defer logger.Shutdown(ctx) // Flushes OTEL + local buffers

Notes:

  • Sync() flushes only local buffers
  • Shutdown(ctx) flushes OTEL exporters AND local buffers
  • Always use Shutdown for OTEL-enabled loggers
Runtime Level Changes

Change log level without restart (thread-safe):

logger.SetLevel("debug")
// Later...
logger.SetLevel("info")

Performance

Ion is optimized for minimal allocations:

Scenario Allocations Latency
Background context 1 alloc ~50ns
With trace context 2 allocs ~170ns
Field: ion.String() 0 allocs
Field: ion.F() 1 alloc

Best Practices:

  1. Use typed field constructors (ion.String, ion.Int) instead of ion.F
  2. Use context.Background() for startup logs (skips trace extraction)

Blockchain Field Helpers

Import specialized helpers for consistent field naming:

import "github.com/JupiterMetaLabs/ion/fields"

logger.Info(ctx, "transaction routed",
    fields.TxHash("abc123"),
    fields.ShardID(5),
    fields.LatencyMs(12.5),
    fields.Slot(12345678),
)

Architecture

Ion wraps zap.Logger with a custom Core for OTEL integration:

  • Console/File: Handled directly by Zap (minimal overhead).
  • OTEL: Asynchronous batch processor (non-blocking).

License

MIT © 2025 JupiterMeta Labs

Documentation

Overview

Package ion provides enterprise-grade structured logging for JupiterMeta blockchain services.

Ion wraps the high-performance Zap logger with OpenTelemetry integration, offering a simple yet powerful API for consistent, observable logging across microservices.

Key Features

  • Pool-optimized hot paths with minimal allocations
  • Built-in OpenTelemetry (OTEL) integration for log export
  • Automatic context propagation (trace_id, span_id)
  • Specialized field helpers for blockchain primitives (TxHash, Slot, ShardID)
  • Configurable output formats (JSON for production, Pretty for development)
  • Log rotation and compression via lumberjack

Quick Start

Global logger pattern (recommended for applications):

package main

import (
    "context"

    "github.com/JupiterMetaLabs/ion"
)

func main() {
    ctx := context.Background()

    ion.SetGlobal(ion.InitFromEnv())
    defer ion.Sync()

    ion.Info(ctx, "application started", ion.String("version", "1.0.0"))
}

Dependency Injection

For libraries or explicit dependencies, pass Logger directly:

func NewServer(logger ion.Logger) *Server {
    return &Server{log: logger.Named("server")}
}

func (s *Server) Start(ctx context.Context) {
    s.log.Info(ctx, "server started", ion.Int("port", 8080))
}

Context-First Logging

Context is always the first parameter. Trace IDs are extracted automatically:

func HandleRequest(ctx context.Context) {
    // trace_id and span_id are added to logs if present in ctx
    logger.Info(ctx, "processing request")
}

For startup and shutdown logs where no trace context exists:

ion.Info(context.Background(), "service starting")

Configuration

Ion supports configuration via code or environment variables:

cfg := ion.Default()
cfg.Level = "debug"
cfg.OTEL.Enabled = true
cfg.OTEL.Endpoint = "otel-collector:4317"

logger := ion.New(cfg)

Environment variables supported by InitFromEnv:

LOG_LEVEL        - debug, info, warn, error (default: info)
LOG_DEVELOPMENT  - "true" for pretty console output
SERVICE_NAME     - service name for logs and OTEL
SERVICE_VERSION  - service version for OTEL resources
OTEL_ENDPOINT    - collector address, enables OTEL if set
OTEL_INSECURE    - "true" to disable TLS
OTEL_USERNAME    - Basic Auth username
OTEL_PASSWORD    - Basic Auth password

Package ion provides enterprise-grade structured logging for JupiterMeta blockchain applications.

Ion is designed for distributed systems where trace correlation is critical. All log methods require a context.Context as the first parameter to ensure trace information is never forgotten.

Features:

  • High-performance Zap core with pool-optimized hot paths
  • Multi-destination output (Console, File, OTEL)
  • Blockchain-specific field helpers (TxHash, ShardID, Slot, etc.)
  • Automatic trace context propagation from context.Context
  • Pretty console output for development
  • File rotation via lumberjack
  • OpenTelemetry integration for observability

Basic usage:

ctx := context.Background()
logger := ion.New(ion.Default())
defer logger.Sync()

logger.Info(ctx, "server started", ion.Int("port", 8080))

With blockchain fields:

import "github.com/JupiterMetaLabs/ion/fields"

logger.Info(ctx, "transaction routed",
    fields.TxHash("abc123"),
    fields.ShardID(5),
    fields.LatencyMs(12.5),
)

Context-first design ensures trace_id and span_id are automatically extracted:

func HandleRequest(ctx context.Context) {
    // trace_id and span_id from ctx are added to logs automatically
    logger.Info(ctx, "processing request")
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug added in v0.1.1

func Debug(ctx context.Context, msg string, fields ...Field)

Debug logs a message at debug level to the global logger.

func Error added in v0.1.1

func Error(ctx context.Context, msg string, err error, fields ...Field)

Error logs a message at error level to the global logger.

func Fatal added in v0.1.1

func Fatal(ctx context.Context, msg string, err error, fields ...Field)

Fatal logs a message at fatal level to the global logger.

func Info added in v0.1.1

func Info(ctx context.Context, msg string, fields ...Field)

Info logs a message at info level to the global logger.

func NewFileWriter

func NewFileWriter(cfg FileConfig) io.Writer

NewFileWriter creates a file writer with rotation using lumberjack. Returns nil if the path is empty.

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext extracts the request ID from context.

func SetGlobal

func SetGlobal(l Logger)

SetGlobal sets the global logger instance. Applications should call this during initialization.

func Shutdown added in v0.1.1

func Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the global logger.

func Sync added in v0.1.1

func Sync() error

Sync flushes the global logger.

func UserIDFromContext

func UserIDFromContext(ctx context.Context) string

UserIDFromContext extracts the user ID from context.

func Warn added in v0.1.1

func Warn(ctx context.Context, msg string, fields ...Field)

Warn logs a message at warn level to the global logger.

func WithRequestID

func WithRequestID(ctx context.Context, requestID string) context.Context

WithRequestID adds a request ID to the context. This ID will be automatically included in logs.

func WithTraceID

func WithTraceID(ctx context.Context, traceID string) context.Context

WithTraceID adds a trace ID to the context (for non-OTEL scenarios).

func WithUserID

func WithUserID(ctx context.Context, userID string) context.Context

WithUserID adds a user ID to the context.

Types

type Config

type Config struct {
	// Level sets the minimum log level: debug, info, warn, error.
	// Default: "info"
	Level string `yaml:"level" json:"level" env:"LOG_LEVEL"`

	// Development enables development mode with:
	// - Pretty console output by default
	// - Caller information in logs
	// - Stack traces on error/fatal
	Development bool `yaml:"development" json:"development" env:"LOG_DEVELOPMENT"`

	// ServiceName identifies this service in logs and OTEL.
	// Default: "unknown"
	ServiceName string `yaml:"service_name" json:"service_name" env:"SERVICE_NAME"`

	// Version is the application version, included in logs.
	Version string `yaml:"version" json:"version" env:"SERVICE_VERSION"`

	// Console output configuration.
	Console ConsoleConfig `yaml:"console" json:"console"`

	// File output configuration (with rotation).
	File FileConfig `yaml:"file" json:"file"`

	// OTEL (OpenTelemetry) exporter configuration.
	OTEL OTELConfig `yaml:"otel" json:"otel"`
}

Config holds the complete logger configuration.

func Default

func Default() Config

Default returns a Config with sensible production defaults.

func Development

func Development() Config

Development returns a Config optimized for development.

func (Config) WithFile

func (c Config) WithFile(path string) Config

WithFile returns a copy of the config with file logging enabled.

func (Config) WithLevel

func (c Config) WithLevel(level string) Config

WithLevel returns a copy of the config with the specified level.

func (Config) WithOTEL

func (c Config) WithOTEL(endpoint string) Config

WithOTEL returns a copy of the config with OTEL enabled.

func (Config) WithService

func (c Config) WithService(name string) Config

WithService returns a copy of the config with the specified service name.

type ConsoleConfig

type ConsoleConfig struct {
	// Enabled controls whether console output is active.
	// Default: true
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Format: "json" for structured JSON, "pretty" for human-readable.
	// Default: "json" (production), "pretty" (development)
	Format string `yaml:"format" json:"format"`

	// Color enables ANSI colors in pretty format.
	// Default: true
	Color bool `yaml:"color" json:"color"`

	// ErrorsToStderr sends warn/error/fatal to stderr, others to stdout.
	// Default: true
	ErrorsToStderr bool `yaml:"errors_to_stderr" json:"errors_to_stderr"`
}

ConsoleConfig configures console (stdout/stderr) output.

type Field

type Field struct {
	Key       string
	Type      FieldType
	Integer   int64
	StringVal string
	Float     float64
	Interface any
}

Field represents a structured logging field (key-value pair). Field construction is zero-allocation for primitive types (String, Int, etc).

func Bool

func Bool(key string, value bool) Field

Bool creates a boolean field.

func Err

func Err(err error) Field

Err creates an error field with the standard key "error".

func F

func F(key string, value any) Field

F is a convenience constructor for Field. It detects the type and creates the appropriate Field.

func Float64

func Float64(key string, value float64) Field

Float64 creates a float64 field.

func Int

func Int(key string, value int) Field

Int creates an integer field.

func Int64

func Int64(key string, value int64) Field

Int64 creates an int64 field.

func String

func String(key, value string) Field

String creates a string field.

type FieldType

type FieldType uint8

FieldType roughly mirrors zapcore.FieldType

const (
	UnknownType FieldType = iota
	StringType
	Int64Type
	Float64Type
	BoolType
	ErrorType
	AnyType
)

type FileConfig

type FileConfig struct {
	// Enabled controls whether file output is active.
	// Default: false
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Path is the log file path.
	// Example: "/var/log/app/app.log"
	Path string `yaml:"path" json:"path"`

	// MaxSizeMB is the maximum size in MB before rotation.
	// Default: 100
	MaxSizeMB int `yaml:"max_size_mb" json:"max_size_mb"`

	// MaxAgeDays is the maximum age in days to retain old logs.
	// Default: 7
	MaxAgeDays int `yaml:"max_age_days" json:"max_age_days"`

	// MaxBackups is the maximum number of old log files to keep.
	// Default: 5
	MaxBackups int `yaml:"max_backups" json:"max_backups"`

	// Compress enables gzip compression of rotated log files.
	// Default: true
	Compress bool `yaml:"compress" json:"compress"`
}

FileConfig configures file output with rotation.

type Logger

type Logger interface {
	// Debug logs a message at debug level.
	Debug(ctx context.Context, msg string, fields ...Field)

	// Info logs a message at info level.
	Info(ctx context.Context, msg string, fields ...Field)

	// Warn logs a message at warn level.
	Warn(ctx context.Context, msg string, fields ...Field)

	// Error logs a message at error level with an error.
	Error(ctx context.Context, msg string, err error, fields ...Field)

	// Fatal logs a message at fatal level and calls os.Exit(1).
	Fatal(ctx context.Context, msg string, err error, fields ...Field)

	// With returns a child logger with additional fields attached.
	// Fields are included in all subsequent log entries.
	With(fields ...Field) Logger

	// Named returns a named sub-logger.
	// The name appears in logs as the "component" field.
	Named(name string) Logger

	// Sync flushes any buffered log entries.
	// Applications should call Sync before exiting.
	Sync() error

	// Shutdown gracefully shuts down the logger, flushing any buffered logs
	// and closing background resources (like OTEL exporters).
	Shutdown(ctx context.Context) error

	// SetLevel changes the log level at runtime.
	// Valid levels: debug, info, warn, error, fatal.
	SetLevel(level string)

	// GetLevel returns the current log level as a string.
	GetLevel() string
}

Logger is the primary logging interface. All methods are safe for concurrent use. All log methods require a context.Context as the first parameter for trace correlation.

Example
ctx := context.Background()

// 1. Initialize the logger
logger := New(Development())
defer func() { _ = logger.Sync() }()

// 2. Log a simple message (context-first)
logger.Info(ctx, "Hello, World!")

// 3. Log with structured fields
logger.Info(ctx, "User logged in",
	F("user_id", 42),
	F("ip", "192.168.1.1"),
)
Example (ContextIntegration)
// Initialize logger
logger := New(Default())
defer func() { _ = logger.Sync() }()

// Create a context (in a real app, this comes from the request)
ctx := context.Background()
ctx = WithRequestID(ctx, "req-123")

// Context is ALWAYS the first parameter
// Trace IDs are extracted automatically
logger.Info(ctx, "Processing request")

func GetGlobal

func GetGlobal() Logger

GetGlobal returns the current global logger instance.

func InitFromEnv added in v0.1.1

func InitFromEnv() Logger

InitFromEnv initializes a logger using environment variables. This is the recommended way to configure ion in production deployments.

Supported variables:

  • LOG_LEVEL: debug, info, warn, error (default: info)
  • LOG_DEVELOPMENT: "true" for pretty console output
  • SERVICE_NAME: name of the service (default: unknown)
  • SERVICE_VERSION: version of the service
  • OTEL_ENDPOINT: collector address, enables OTEL if set (e.g., "localhost:4317")
  • OTEL_INSECURE: "true" to disable TLS for OTEL connection
  • OTEL_USERNAME: Basic Auth username for OTEL collector
  • OTEL_PASSWORD: Basic Auth password for OTEL collector

func L

func L() Logger

L is a shorthand for GetGlobal().

func Named added in v0.1.1

func Named(name string) Logger

Named returns a named sub-logger from the global logger.

func New

func New(cfg Config) Logger

New creates a new Logger from the provided configuration. This is the main constructor for ion.

func NewWithOTEL

func NewWithOTEL(cfg Config) (Logger, error)

NewWithOTEL creates a logger with OTEL export enabled. This wires Zap logs to the OpenTelemetry log pipeline.

func With added in v0.1.1

func With(fields ...Field) Logger

With returns a child logger from the global logger.

type OTELConfig

type OTELConfig struct {
	// Enabled controls whether OTEL export is active.
	// Default: false
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Protocol: "grpc" or "http". gRPC is recommended for performance.
	// Default: "grpc"
	Protocol string `yaml:"protocol" json:"protocol"`

	// Endpoint is the OTEL collector endpoint.
	// Examples: "localhost:4317" (gRPC), "localhost:4318/v1/logs" (HTTP)
	Endpoint string `yaml:"endpoint" json:"endpoint"`

	// Insecure disables TLS for the connection.
	// Default: false
	Insecure bool `yaml:"insecure" json:"insecure"`

	// Username for Basic Authentication (optional).
	Username string `yaml:"username" json:"username" env:"OTEL_USERNAME"`

	// Password for Basic Authentication (optional).
	Password string `yaml:"password" json:"password" env:"OTEL_PASSWORD"`

	// Headers are additional headers to send (e.g., auth tokens).
	Headers map[string]string `yaml:"headers" json:"headers"`

	// Timeout is the export timeout.
	// Default: 10s
	Timeout time.Duration `yaml:"timeout" json:"timeout"`

	// BatchSize is the number of logs per export batch.
	// Default: 512
	BatchSize int `yaml:"batch_size" json:"batch_size"`

	// ExportInterval is how often to export batched logs.
	// Default: 5s
	ExportInterval time.Duration `yaml:"export_interval" json:"export_interval"`

	// Attributes are additional resource attributes for OTEL.
	// Example: {"environment": "production", "chain": "solana"}
	Attributes map[string]string `yaml:"attributes" json:"attributes"`
}

OTELConfig configures OpenTelemetry log export.

type TelemetryLog

type TelemetryLog struct {
	// contains filtered or unexported fields
}

TelemetryLog provides a fluent API for trace-coupled logging. It creates both a log entry AND a trace span in a single call.

Usage:

NewTelemetryLog(logger).
    Instrument("example.routing").
    Component("pool").
    Trace("ROUTE_TX").
    Info("transaction routed", fields.TxHash("abc123"))

The log will automatically include trace_id and span_id. Errors automatically mark the span as failed.

func NewTelemetryLog

func NewTelemetryLog(logger Logger) *TelemetryLog

NewTelemetryLog creates a new fluent telemetry logger. Pass the base logger to use for output.

func NewTelemetryLogFromGlobal

func NewTelemetryLogFromGlobal() *TelemetryLog

NewTelemetryLogFromGlobal creates a TelemetryLog using the global logger.

func T

func T() *TelemetryLog

T is a shorthand for creating a TelemetryLog from the global logger.

func (*TelemetryLog) Component

func (t *TelemetryLog) Component(name string) *TelemetryLog

Component sets the component name field.

func (*TelemetryLog) Debug

func (t *TelemetryLog) Debug(msg string, fields ...Field)

Debug logs at debug level with optional trace span.

func (*TelemetryLog) Error

func (t *TelemetryLog) Error(msg string, err error, fields ...Field)

Error logs at error level and marks span as error.

func (*TelemetryLog) Info

func (t *TelemetryLog) Info(msg string, fields ...Field)

Info logs at info level with optional trace span.

func (*TelemetryLog) Instrument

func (t *TelemetryLog) Instrument(name string) *TelemetryLog

Instrument sets the OTEL instrumentation scope name. Example: "my-service.routing", "consensus.engine"

func (*TelemetryLog) Level

func (t *TelemetryLog) Level(level zapcore.Level) *TelemetryLog

Level sets the log level.

func (*TelemetryLog) Module

func (t *TelemetryLog) Module(name string) *TelemetryLog

Module sets the module name field.

func (*TelemetryLog) Printf

func (t *TelemetryLog) Printf(format string, args ...any)

Printf is a convenience method for formatted logging.

func (*TelemetryLog) Trace

func (t *TelemetryLog) Trace(spanName string) *TelemetryLog

Trace sets the span name to create. Example: "ROUTE_TX", "VALIDATE_BLOCK", "CONNECT_NODE"

func (*TelemetryLog) Warn

func (t *TelemetryLog) Warn(msg string, fields ...Field)

Warn logs at warn level with optional trace span.

func (*TelemetryLog) WithContext

func (t *TelemetryLog) WithContext(ctx context.Context) *TelemetryLog

WithContext sets the context for trace propagation. If the context already has a span, the new span will be a child.

Directories

Path Synopsis
examples
basic command
Package fields provides blockchain-specific logging field helpers.
Package fields provides blockchain-specific logging field helpers.
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL