mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
libmain-c: add nix_set_log_format function
This commit is contained in:
parent
73d3ab05b6
commit
cf595b81d5
2 changed files with 21 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
#include "nix_api_util_internal.h"
|
#include "nix_api_util_internal.h"
|
||||||
|
|
||||||
#include "nix/main/plugin.hh"
|
#include "nix/main/plugin.hh"
|
||||||
|
#include "nix/main/loggers.hh"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
|
@ -17,4 +18,16 @@ nix_err nix_init_plugins(nix_c_context * context)
|
||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nix_err nix_set_log_format(nix_c_context * context, const char * format)
|
||||||
|
{
|
||||||
|
if (context)
|
||||||
|
context->last_err_code = NIX_OK;
|
||||||
|
if (format == nullptr)
|
||||||
|
return nix_set_err_msg(context, NIX_ERR_UNKNOWN, "Log format is null");
|
||||||
|
try {
|
||||||
|
nix::setLogFormat(format);
|
||||||
|
}
|
||||||
|
NIXC_CATCH_ERRS
|
||||||
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,14 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
nix_err nix_init_plugins(nix_c_context * context);
|
nix_err nix_init_plugins(nix_c_context * context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the log format
|
||||||
|
*
|
||||||
|
* @param[out] context Optional, stores error information
|
||||||
|
* @param[in] format The string name of the format.
|
||||||
|
*/
|
||||||
|
nix_err nix_set_log_format(nix_c_context * context, const char * format);
|
||||||
|
|
||||||
// cffi end
|
// cffi end
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue