Added CLICON_LOG_DESTINATION and CLICON_LOG_FILE for al applications

This commit is contained in:
Olof hagsand 2024-06-19 12:28:39 +02:00
parent 26062d7003
commit 0234ed94bc
22 changed files with 498 additions and 163 deletions

View file

@ -46,9 +46,10 @@
* Constants
*/
/* Debug flags are seperated into subject areas and detail
/*! Debug flags are separated into subject areas and detail
*
* @see dbgmap Symbolic mapping (if you change here you may need to change dbgmap)
* @see clixon_debug in clixon-lib.yang
* @see also clixon_debug_t in clixon-lib.yang
*/
/* Detail level */
#define CLIXON_DBG_ALWAYS 0x00000000 /* Unconditionally logged */

View file

@ -45,11 +45,15 @@
/*
* Constants
*/
/* Where to log (masks) */
#define CLIXON_LOG_SYSLOG 1 /* print logs on syslog */
#define CLIXON_LOG_STDERR 2 /* print logs on stderr */
#define CLIXON_LOG_STDOUT 4 /* print logs on stdout */
#define CLIXON_LOG_FILE 8 /* print logs on clicon_log_filename */
/*! Log destination as bitfields (masks)
*
* @see logdstmap Symbolic mapping (if you change here you may need to change logdstmap)
* @see also log_desination_t in clixon-config.yang
*/
#define CLIXON_LOG_SYSLOG 0x01 /* print logs on syslog */
#define CLIXON_LOG_STDERR 0x02 /* print logs on stderr */
#define CLIXON_LOG_STDOUT 0x04 /* print logs on stdout */
#define CLIXON_LOG_FILE 0x08 /* print logs on clixon_log_filename */
/* What kind of log (only for customizable error/logs) */
enum clixon_log_type{
@ -67,6 +71,8 @@ enum clixon_log_type{
/*
* Prototypes
*/
char *clixon_logdst_key2str(int keyword);
int clixon_logdst_str2key(char *str);
int clixon_log_init(clixon_handle h, char *ident, int upto, int flags);
int clixon_log_exit(void);
int clixon_log_opt(char c);

View file

@ -112,6 +112,9 @@ int clicon_option_add(clixon_handle h, const char *name, char *value);
/* Initialize options: set defaults, read config-file, etc */
int clicon_options_main(clixon_handle h);
/* Options debug and log helper function */
int clixon_options_main_helper(clixon_handle h, uint32_t dbg, uint32_t logdst, char *ident);
/*! Check if a clicon option has a value */
int clicon_option_exists(clixon_handle h, const char *name);

View file

@ -77,8 +77,10 @@ int assign_namespace_element(cxobj *x0, cxobj *x1, cxobj *x1p);
int assign_namespace_body(cxobj *x0, cxobj *x1);
int xml_merge(cxobj *x0, cxobj *x1, yang_stmt *yspec, char **reason);
int yang_valstr2enum(yang_stmt *ytype, char *valstr, char **enumstr);
int yang_bitsstr2val(clixon_handle h, yang_stmt *ytype, char *bitsstr, unsigned char **snmpval, size_t *snmplen);
int yang_val2bitsstr(clixon_handle h, yang_stmt *ytype, unsigned char *snmpval, size_t snmplen, cbuf *cb);
int yang_bitsstr2val(clixon_handle h, yang_stmt *ytype, char *bitsstr, unsigned char **outval, size_t *outlen);
int yang_bitsstr2flags(yang_stmt *ytype, char *bitsstr, uint32_t *flags);
int yang_val2bitsstr(clixon_handle h, yang_stmt *ytype, unsigned char *outval, size_t snmplen, cbuf *cb);
int yang_bits_map(yang_stmt *yt, char *str, char *nodeid, uint32_t *flags);
int yang_enum2valstr(yang_stmt *ytype, char *enumstr, char **valstr);
int yang_enum2int(yang_stmt *ytype, char *enumstr, int32_t *val);
int yang_enum_int_value(cxobj *node, int32_t *val);