logging

package
v0.0.0-...-1e60831 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: NIST-PD-fallback Imports: 4 Imported by: 0

README

ndn-dpdk/core/logging

NDN-DPDK implements structured logging. Log entries are written to stderr in JSON format.

Loggers

NDN-DPDK components are organized into named loggers. You can find all logger names in the codebase with this command:

git grep -wE 'N_LOG_INIT|logging\.New'

In addition:

  • "DPDK" refers to DPDK libraries and drivers.
  • "SPDK" refers to SPDK libraries and drivers.

Log Level Configuration

Log level of each logger can be configured through environment variables. For logger "Foo", the initialization code first looks for "NDNDPDK_LOG_Foo" and, if not found, looks for the generic "NDNDPDK_LOG" environment variable. The value of this environment variable should be one of the values in "env" column:

env Go level C level DPDK level SPDK level
V DEBUG VERBOSE DEBUG DEBUG
D DEBUG DEBUG INFO INFO
I INFO INFO NOTICE NOTICE
W WARNING WARNING WARNING WARNING
E ERROR ERROR ERR ERROR
F FATAL (none) CRIT (none)
N FATAL (none) ALERT (none)

When the NDN-DPDK service is running, you can retrieve and change log levels via GraphQL (implemented in package logginggql).

Internals

|--------|
|NDN-DPDK|  |------|  |------|
| C code |  | DPDK |  | SPDK |
|---+----|  |--+---|  |--+---|
    |          |         |
  |-v----------v---------v-|
  | DPDK rte_log.h library |
  |----------+-------------|
             |                   |--------|
|------------v---------------|   |NDN-DPDK|
| ealinit.processLogStream() |   |Go code |
|-------------------------+--|   |--+-----|
                           \       /
                          |-v-----v-|
                          |   zap   |
                          |---------|

Go code uses zap structured logging library. It is initialized in this package.

C code logs to DPDK logging library. It generally uses a semi-structured format, where each line starts with a freeform message, followed by zero or more key-value pairs.

Package spdkenv configures SPDK to log to DPDK logging library.

Package ealinit redirects DPDK log messages (including messages from NDN-DPDK C code and SPDK) to zap. It creates a Unix pipe, and configures DPDK logging library to write to the pipe. Then, it creates a goroutine that reads from the pipe, parses messages, and emits as zap log entries.

Documentation

Overview

Package logging is a thin wrapper of zap logging library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Named

func Named(pkg string) *zap.Logger

Named creates a named logger without initialization.

func New

func New(pkg string) *zap.Logger

New creates a logger initialized with configured log level.

By NDN-DPDK codebase convention, this should appear in the same .go file as the package docstring:

var logger = logging.New("Foo")

func StdLogger

func StdLogger(logger *zap.Logger, lvl zapcore.Level) *log.Logger

StdLogger creates a log.Logger that logs to zap.Logger at specified level.

Types

type PkgLevel

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

PkgLevel represents log level of a package.

func FindLevel

func FindLevel(pkg string) (pl *PkgLevel)

FindLevel returns package log level object.

func GetLevel

func GetLevel(pkg string) (pl *PkgLevel)

GetLevel finds or creates package log level object.

func ListLevels

func ListLevels() (list []PkgLevel)

ListLevels returns all package levels.

func (PkgLevel) Level

func (pl PkgLevel) Level() byte

Level returns log level.

func (PkgLevel) Package

func (pl PkgLevel) Package() string

Package returns package name.

func (*PkgLevel) SetCallback

func (pl *PkgLevel) SetCallback(cb func())

SetCallback sets a callback for level changing.

func (*PkgLevel) SetLevel

func (pl *PkgLevel) SetLevel(input string)

SetLevel assigns log level.

Directories

Path Synopsis
Package logginggql allows setting log levels via GraphQL.
Package logginggql allows setting log levels via GraphQL.

Jump to

Keyboard shortcuts

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