Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
logging.hh File Reference
#include "lix/libutil/types.hh"
#include "lix/libutil/error.hh"
#include "lix/libutil/config.hh"
#include "logging-settings.gen.inc"

Go to the source code of this file.

Classes

struct  nix::json::is_integral_enum< ActivityType >
struct  nix::json::is_integral_enum< ResultType >
struct  nix::LoggerSettings
class  nix::Logger
struct  nix::Logger::Field
struct  nix::nop
struct  nix::Activity
class  nix::PushActivity

Macros

#define logErrorInfo(level, errorInfo...)
#define logError(errorInfo...)
#define logWarning(errorInfo...)
#define printMsgUsing(loggerParam, level, args...)
#define printMsg(level, args...)
#define printError(args...)
#define notice(args...)
#define printInfo(args...)
#define printTalkative(args...)
#define debug(args...)
#define vomit(args...)

Typedefs

typedef uint64_t nix::ActivityId

Enumerations

enum  nix::ActivityType {
  actUnknown = 0 , actCopyPath = 100 , actFileTransfer = 101 , actRealise = 102 ,
  actCopyPaths = 103 , actBuilds = 104 , nix::actBuild = 105 , actOptimiseStore = 106 ,
  actVerifyPaths = 107 , nix::actSubstitute = 108 , nix::actQueryPathInfo = 109 , nix::actPostBuildHook = 110 ,
  actBuildWaiting = 111
}
enum  nix::ResultType {
  nix::resFileLinked = 100 , nix::resBuildLogLine = 101 , resUntrustedPath = 102 , resCorruptedPath = 103 ,
  nix::resSetPhase = 104 , nix::resProgress = 105 , nix::resSetExpected = 106 , nix::resPostBuildLogLine = 107
}

Functions

ActivityId nix::getCurActivity ()
void nix::setCurActivity (const ActivityId activityId)
Loggernix::makeSimpleLogger (bool printBuildLogs)
Loggernix::makeJSONLogger (Logger &prevLogger)
template<typename... Args>
void nix::warn (const std::string &fs, const Args &... args)
void nix::writeLogsToStderr (std::string_view s)
void nix::logFatal (std::string const &s)
std::optional< JSON > nix::parseJSONMessage (const std::string &msg, std::string_view source)
bool nix::handleJSONLogMessage (JSON &json, const Activity &act, std::map< ActivityId, Activity > &activities, std::string_view source, bool trusted)
bool nix::handleJSONLogMessage (const std::string &msg, const Activity &act, std::map< ActivityId, Activity > &activities, std::string_view source, bool trusted)

Macro Definition Documentation

◆ debug

#define debug ( args...)
Value:
printMsg(lvlDebug, args)

◆ logError

#define logError ( errorInfo...)
Value:
logErrorInfo(lvlError, errorInfo)
#define logErrorInfo(level, errorInfo...)
Definition logging.hh:270

◆ logErrorInfo

#define logErrorInfo ( level,
errorInfo... )
Value:
do { \
if ((level) <= nix::verbosity) { \
logger->logEI((level), errorInfo); \
} \
} while (0)

Print a message with the standard ErrorInfo format. In general, use these 'log' macros for reporting problems that may require user intervention or that need more explanation. Use the 'print' macros for more lightweight status messages.

◆ logWarning

#define logWarning ( errorInfo...)
Value:
logErrorInfo(lvlWarn, errorInfo)

◆ notice

#define notice ( args...)
Value:
printMsg(lvlNotice, args)

◆ printError

#define printError ( args...)
Value:
printMsg(lvlError, args)

◆ printInfo

#define printInfo ( args...)
Value:
printMsg(lvlInfo, args)

◆ printMsg

#define printMsg ( level,
args... )
Value:
printMsgUsing(logger, level, args)
#define printMsgUsing(loggerParam, level, args...)
Definition logging.hh:285

◆ printMsgUsing

#define printMsgUsing ( loggerParam,
level,
args... )
Value:
do { \
auto _lix_logger_print_lvl = level; \
if (_lix_logger_print_lvl <= nix::verbosity) { \
loggerParam->log(_lix_logger_print_lvl, fmt(args)); \
} \
} while (0)

Print a string message if the current log level is at least the specified level. Note that this has to be implemented as a macro to ensure that the arguments are evaluated lazily.

◆ printTalkative

#define printTalkative ( args...)
Value:
printMsg(lvlTalkative, args)

◆ vomit

#define vomit ( args...)
Value:
printMsg(lvlVomit, args)

Enumeration Type Documentation

◆ ActivityType

Enumerator
actBuild 

Fields: 0: string: path to store derivation being built. 1: string: representing the machine this is being built on. Empty string if local machine. 2: int: curRound, not used anymore, always 1? 3: int: nrRounds, not used anymore always 1?

actSubstitute 

Fields: 0: string: store path 1: string: substituter

actQueryPathInfo 

Fields: 0: string: store path 1: string: substituter

actPostBuildHook 

Fields: 0: string: store path

◆ ResultType

Enumerator
resFileLinked 

Fields: 0: int: bytes linked

resBuildLogLine 

Fields: 0: string: last line

resSetPhase 

Fields: 0: string: phase name

resProgress 

Fields: 0: int: done 1: int: expected 2: int: running 3: int: failed

resSetExpected 

Fields: 0: int: ActivityType 1: int: expected

resPostBuildLogLine 

Fields: 0: string: last line

Function Documentation

◆ handleJSONLogMessage() [1/2]

bool nix::handleJSONLogMessage ( const std::string & msg,
const Activity & act,
std::map< ActivityId, Activity > & activities,
std::string_view source,
bool trusted )
Parameters
sourceA noun phrase describing the source of the message, e.g. "the builder".

◆ handleJSONLogMessage() [2/2]

bool nix::handleJSONLogMessage ( JSON & json,
const Activity & act,
std::map< ActivityId, Activity > & activities,
std::string_view source,
bool trusted )
Parameters
sourceA noun phrase describing the source of the message, e.g. "the builder".

◆ logFatal()

void nix::logFatal ( std::string const & s)

Logs a fatal message as loudly as possible. This will go into syslog as well as stderr. The purpose of this function is making failures with redirected stderr louder.

◆ parseJSONMessage()

std::optional< JSON > nix::parseJSONMessage ( const std::string & msg,
std::string_view source )
Parameters
sourceA noun phrase describing the source of the message, e.g. "the builder".

◆ warn()

template<typename... Args>
void nix::warn ( const std::string & fs,
const Args &... args )
inline

if verbosity >= lvlWarn, print a message with a yellow 'warning:' prefix.