mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 12:06:01 +01:00
libutil-c: add nix_set_verbosity function
This commit is contained in:
parent
cf595b81d5
commit
bb6a4dccdf
2 changed files with 38 additions and 0 deletions
|
|
@ -159,4 +159,16 @@ nix_err call_nix_get_string_callback(const std::string str, nix_get_string_callb
|
||||||
return NIX_OK;
|
return NIX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nix_err nix_set_verbosity(nix_c_context * context, nix_verbosity level)
|
||||||
|
{
|
||||||
|
if (context)
|
||||||
|
context->last_err_code = NIX_OK;
|
||||||
|
if (level > NIX_LVL_VOMIT || level < NIX_LVL_ERROR)
|
||||||
|
return nix_set_err_msg(context, NIX_ERR_UNKNOWN, "Invalid verbosity level");
|
||||||
|
try {
|
||||||
|
nix::verbosity = static_cast<nix::Verbosity>(level);
|
||||||
|
}
|
||||||
|
NIXC_CATCH_ERRS
|
||||||
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,24 @@ enum nix_err {
|
||||||
|
|
||||||
typedef enum nix_err nix_err;
|
typedef enum nix_err nix_err;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Verbosity level
|
||||||
|
*
|
||||||
|
* @note This should be kept in sync with the C++ implementation (nix::Verbosity)
|
||||||
|
*/
|
||||||
|
enum nix_verbosity {
|
||||||
|
NIX_LVL_ERROR = 0,
|
||||||
|
NIX_LVL_WARN,
|
||||||
|
NIX_LVL_NOTICE,
|
||||||
|
NIX_LVL_INFO,
|
||||||
|
NIX_LVL_TALKATIVE,
|
||||||
|
NIX_LVL_CHATTY,
|
||||||
|
NIX_LVL_DEBUG,
|
||||||
|
NIX_LVL_VOMIT,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum nix_verbosity nix_verbosity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This object stores error state.
|
* @brief This object stores error state.
|
||||||
* @struct nix_c_context
|
* @struct nix_c_context
|
||||||
|
|
@ -316,6 +334,14 @@ nix_err nix_set_err_msg(nix_c_context * context, nix_err err, const char * msg);
|
||||||
*/
|
*/
|
||||||
void nix_clear_err(nix_c_context * context);
|
void nix_clear_err(nix_c_context * context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the verbosity level
|
||||||
|
*
|
||||||
|
* @param[out] context Optional, additional error context.
|
||||||
|
* @param[in] level Verbosity level
|
||||||
|
*/
|
||||||
|
nix_err nix_set_verbosity(nix_c_context * context, nix_verbosity level);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue