1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 12:06:01 +01:00

libmain-c: add nix_set_log_format function

This commit is contained in:
Tristan Ross 2025-09-23 12:04:06 -07:00
parent 73d3ab05b6
commit cf595b81d5
No known key found for this signature in database
GPG key ID: 58BB826E9F8688F4
2 changed files with 21 additions and 0 deletions

View file

@ -4,6 +4,7 @@
#include "nix_api_util_internal.h"
#include "nix/main/plugin.hh"
#include "nix/main/loggers.hh"
extern "C" {
@ -17,4 +18,16 @@ nix_err nix_init_plugins(nix_c_context * context)
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"

View file

@ -30,6 +30,14 @@ extern "C" {
*/
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
#ifdef __cplusplus
}