package
0.0.0-20250328141702-0be2411d0833
Repository: https://github.com/usnistgov/ndn-dpdk.git
Documentation: pkg.go.dev

# 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:

envGo levelC levelDPDK levelSPDK level
VDEBUGVERBOSEDEBUGDEBUG
DDEBUGDEBUGINFOINFO
IINFOINFONOTICENOTICE
WWARNINGWARNINGWARNINGWARNING
EERRORERRORERRERROR
FFATAL(none)CRIT(none)
NFATAL(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.

# Packages

Package logginggql allows setting log levels via GraphQL.

# Functions

FindLevel returns package log level object.
GetLevel finds or creates package log level object.
ListLevels returns all package levels.
Named creates a named logger without initialization.
New creates a logger initialized with configured log level.
StdLogger creates a log.Logger that logs to zap.Logger at specified level.

# Structs

PkgLevel represents log level of a package.