Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CLEFSink ¶
type CLEFSink struct {
// contains filtered or unexported fields
}
CLEFSink writes log entries as CLEF-compatible JSON lines. Each line is a single JSON object with @t, @l (omitted for Information), @m, and all structured fields flattened at the root level, matching the format emitted by Serilog's RenderedCompactJsonFormatter, so that Go and C# service logs are queryable with the same field selectors in Grafana/Loki.
func NewCLEFSink ¶
NewCLEFSink constructs a CLEFSink. When w is nil, os.Stdout is used.
type ConsoleSink ¶
type ConsoleSink struct {
// contains filtered or unexported fields
}
ConsoleSink writes entries as compact JSON lines to an io.Writer.
func NewConsoleSink ¶
func NewConsoleSink(w io.Writer) *ConsoleSink
NewConsoleSink constructs a ConsoleSink.
func (*ConsoleSink) Log ¶
func (c *ConsoleSink) Log(e Entry) error
Log writes a structured entry to the underlying writer.
type Entry ¶
type Entry struct {
Level string `json:"level"`
Time time.Time `json:"time"`
Msg string `json:"msg"`
Fields map[string]interface{} `json:"fields,omitempty"`
TraceID string `json:"trace_id,omitempty"`
SpanID string `json:"span_id,omitempty"`
}
Entry is the log payload passed to sinks.
type Field ¶
type Field struct {
Key string `json:"key"`
Value interface{} `json:"value"`
}
Field is a single structured key/value pair.
type Level ¶
type Level int
Level represents log severity.
const ( // DebugLevel logs detailed diagnostic information. DebugLevel Level = iota // InfoLevel logs general operational messages. InfoLevel // WarnLevel logs potential problems. WarnLevel // ErrorLevel logs error conditions. ErrorLevel // FatalLevel logs severe errors that should terminate the process. FatalLevel )
Log levels in ascending order of severity.
type Logger ¶
type Logger interface {
With(fields ...Field) Logger
Debug(msg string, fields ...Field)
Info(msg string, fields ...Field)
Warn(msg string, fields ...Field)
Error(msg string, fields ...Field)
RegisterSink(s Sink)
SetLevel(l Level)
}
Logger is the public logging contract.
type Option ¶
type Option func(*stdLogger)
Option configures the concrete logger on creation.
func WithAsync ¶
WithAsync enables asynchronous logging with a buffered channel of the specified size.
func WithContext ¶
WithContext binds a context to the logger, allowing sinks to extract trace/span IDs for distributed tracing.
func WithFields ¶
WithFields binds fields to the logger returned from New.
func WithoutDefaultSink ¶
func WithoutDefaultSink() Option
WithoutDefaultSink removes the default ConsoleSink added by New. Use before WithSink to create a logger with only custom sinks:
logger.New(logger.WithoutDefaultSink(), logger.WithSink(clefSink))