Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
logging.hh File Reference
#include "error.hh"
#include "config.hh"
#include <nlohmann/json_fwd.hpp>

Go to the source code of this file.

Classes

struct  nix::LoggerSettings
 
class  nix::Logger
 
struct  nix::Logger::Field
 
struct  nix::nop
 
struct  nix::Activity
 
struct  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...)
 
#define warnOnce(haveWarned, args...)
 

Typedefs

typedef uint64_t nix::ActivityId
 

Enumerations

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

Functions

ActivityId nix::getCurActivity ()
 
void nix::setCurActivity (const ActivityId activityId)
 
Loggernix::makeSimpleLogger (bool printBuildLogs)
 
Loggernix::makeJSONLogger (Logger &prevLogger)
 
std::optional< nlohmann::json > nix::parseJSONMessage (const std::string &msg, std::string_view source)
 
bool nix::handleJSONLogMessage (nlohmann::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)
 
template<typename... Args>
void nix::warn (const std::string &fs, const Args &... args)
 
void nix::writeToStderr (std::string_view s)
 

Macro Definition Documentation

◆ debug

#define debug ( args...)
Value:
printMsg(lvlDebug, args)
std::vector< Expr * > args
Definition lexer.l:6126

◆ logError

#define logError ( errorInfo...)
Value:
logErrorInfo(lvlError, errorInfo)

◆ 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)

◆ printMsgUsing

#define printMsgUsing ( loggerParam,
level,
args... )
Value:
do { \
auto __lvl = level; \
if (__lvl <= nix::verbosity) { \
loggerParam->log(__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)

◆ warnOnce

#define warnOnce ( haveWarned,
args... )
Value:
if (!haveWarned) { \
haveWarned = true; \
warn(args); \
}

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 ( nlohmann::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".

◆ parseJSONMessage()

std::optional< nlohmann::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.