observability

package
v0.9.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Copyright (c) 2025 Nexlayer. All rights reserved.n// Use of this source code is governed by an MIT-stylen// license that can be found in the LICENSE file.nn Package observability provides logging and metrics for the Nexlayer CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogLevel

type LogLevel string

LogLevel represents the logging level

const (
	// Log levels
	DEBUG LogLevel = "debug"
	INFO  LogLevel = "info"
	WARN  LogLevel = "warn"
	ERROR LogLevel = "error"
)

type LogOption

type LogOption func(*Logger)

LogOption represents logger configuration options

func WithJSON

func WithJSON() LogOption

WithJSON enables JSON logging format

func WithLevel

func WithLevel(level LogLevel) LogOption

WithLevel sets the logging level

func WithRotation

func WithRotation(maxSizeMB int, maxDays int) LogOption

WithRotation enables log rotation with specified size and days

type Logger

type Logger struct {
	*zap.SugaredLogger
	// contains filtered or unexported fields
}

Logger wraps zap logger with CLI-specific methods

func NewLogger

func NewLogger(level LogLevel, opts ...LogOption) *Logger

NewLogger creates a new CLI logger

func (*Logger) Debug

func (l *Logger) Debug(ctx context.Context, format string, args ...interface{})

Debug logs a debug message with context

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, format string, args ...interface{})

Error logs an error message with context

func (*Logger) Fatal

func (l *Logger) Fatal(ctx context.Context, format string, args ...interface{})

Fatal logs a fatal message with context and exits

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, format string, args ...interface{})

Info logs an info message with context

func (*Logger) Sync

func (l *Logger) Sync() error

Sync flushes any buffered log entries

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, format string, args ...interface{})

Warn logs a warning message with context

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *Logger

WithField adds a field to the logger

func (*Logger) WithFields

func (l *Logger) WithFields(fields map[string]interface{}) *Logger

WithFields adds multiple fields to the logger

Jump to

Keyboard shortcuts

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