Replaced clixon_get_logflags() with clixon_logflags_get()
Added `clixon_logflags_set()`
This commit is contained in:
parent
39fb149756
commit
1709537701
5 changed files with 36 additions and 18 deletions
|
|
@ -41,6 +41,7 @@ Users may have to change how they access the system
|
||||||
|
|
||||||
Developers may need to change their code
|
Developers may need to change their code
|
||||||
|
|
||||||
|
* Replaced `clixon_get_logflags()` with `clixon_logflags_get()`
|
||||||
* New `yn_iter()` yang iterator replaces `yn_each()`
|
* New `yn_iter()` yang iterator replaces `yn_each()`
|
||||||
* Use an integer iterator instead of yang object
|
* Use an integer iterator instead of yang object
|
||||||
* Replace `y1 = NULL; y1 = yn_each(y0, y1)` with `int inext = 0; yn_iter(y0, &inext)`
|
* Replace `y1 = NULL; y1 = yn_each(y0, y1)` with `int inext = 0; yn_iter(y0, &inext)`
|
||||||
|
|
|
||||||
|
|
@ -977,7 +977,7 @@ main(int argc,
|
||||||
free(restarg);
|
free(restarg);
|
||||||
/* Dont log terminate on stderr or stdout */
|
/* Dont log terminate on stderr or stdout */
|
||||||
clixon_log_init(h, __PROGRAM__, LOG_INFO,
|
clixon_log_init(h, __PROGRAM__, LOG_INFO,
|
||||||
clixon_get_logflags() & ~(CLIXON_LOG_STDERR|CLIXON_LOG_STDOUT));
|
clixon_logflags_get() & ~(CLIXON_LOG_STDERR|CLIXON_LOG_STDOUT));
|
||||||
clixon_log(h, LOG_NOTICE, "%s: %u Terminated", __PROGRAM__, getpid());
|
clixon_log(h, LOG_NOTICE, "%s: %u Terminated", __PROGRAM__, getpid());
|
||||||
if (h)
|
if (h)
|
||||||
cli_terminate(h);
|
cli_terminate(h);
|
||||||
|
|
|
||||||
|
|
@ -487,7 +487,7 @@ cli_handler_err(FILE *f)
|
||||||
{
|
{
|
||||||
if (clixon_err_category()){
|
if (clixon_err_category()){
|
||||||
/* Check if error is already logged on stderr */
|
/* Check if error is already logged on stderr */
|
||||||
if ((clixon_get_logflags() & CLIXON_LOG_STDERR) == 0){
|
if ((clixon_logflags_get() & CLIXON_LOG_STDERR) == 0){
|
||||||
if (clixon_err_category() != -1)
|
if (clixon_err_category() != -1)
|
||||||
fprintf(f, "%s: ", clixon_err_str());
|
fprintf(f, "%s: ", clixon_err_str());
|
||||||
fprintf(f, "%s", clixon_err_reason());
|
fprintf(f, "%s", clixon_err_reason());
|
||||||
|
|
@ -537,7 +537,7 @@ clicon_parse(clixon_handle h,
|
||||||
pt_head *ph;
|
pt_head *ph;
|
||||||
|
|
||||||
ch = cli_cligen(h);
|
ch = cli_cligen(h);
|
||||||
if (clixon_get_logflags()&CLIXON_LOG_STDOUT)
|
if (clixon_logflags_get()&CLIXON_LOG_STDOUT)
|
||||||
f = stdout;
|
f = stdout;
|
||||||
else
|
else
|
||||||
f = stderr;
|
f = stderr;
|
||||||
|
|
|
||||||
|
|
@ -68,19 +68,25 @@ enum clixon_log_type{
|
||||||
#define clixon_log(h, l, _fmt, args...) clixon_log_fn((h), 1, (l), NULL, _fmt , ##args)
|
#define clixon_log(h, l, _fmt, args...) clixon_log_fn((h), 1, (l), NULL, _fmt , ##args)
|
||||||
#define clixon_log_xml(h, l, x, _fmt, args...) clixon_log_fn((h), 1, (l), x, _fmt , ##args)
|
#define clixon_log_xml(h, l, x, _fmt, args...) clixon_log_fn((h), 1, (l), x, _fmt , ##args)
|
||||||
|
|
||||||
|
// COMPAT_7_1
|
||||||
|
#define clixon_get_logflags() clixon_logflags_get()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
char *clixon_logdst_key2str(int keyword);
|
char *clixon_logdst_key2str(int keyword);
|
||||||
int clixon_logdst_str2key(char *str);
|
int clixon_logdst_str2key(char *str);
|
||||||
int clixon_log_init(clixon_handle h, char *ident, int upto, int flags);
|
int clixon_log_init(clixon_handle h, char *ident, int upto, uint16_t flags);
|
||||||
int clixon_log_exit(void);
|
int clixon_log_exit(void);
|
||||||
int clixon_log_opt(char c);
|
int clixon_log_opt(char c);
|
||||||
int clixon_log_file(char *filename);
|
int clixon_log_file(char *filename);
|
||||||
int clixon_log_string_limit_set(size_t sz);
|
int clixon_log_string_limit_set(size_t sz);
|
||||||
size_t clixon_log_string_limit_get(void);
|
size_t clixon_log_string_limit_get(void);
|
||||||
int clixon_get_logflags(void);
|
uint16_t clixon_logflags_get(void);
|
||||||
int clixon_log_str(int level, char *msg);
|
int clixon_logflags_set(uint16_t flags);
|
||||||
int clixon_log_fn(clixon_handle h, int user, int level, cxobj *x, const char *format, ...) __attribute__ ((format (printf, 5, 6)));
|
int clixon_log_str(int level, char *msg);
|
||||||
|
int clixon_log_fn(clixon_handle h, int user, int level, cxobj *x, const char *format, ...) __attribute__ ((format (printf, 5, 6)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CLIXON_LOG_H_ */
|
#endif /* _CLIXON_LOG_H_ */
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@
|
||||||
static clixon_handle _log_clixon_h = NULL;
|
static clixon_handle _log_clixon_h = NULL;
|
||||||
|
|
||||||
/* Bitmask whether to log to syslog or stderr: CLIXON_LOG_STDERR | CLIXON_LOG_SYSLOG */
|
/* Bitmask whether to log to syslog or stderr: CLIXON_LOG_STDERR | CLIXON_LOG_SYSLOG */
|
||||||
static int _log_flags = 0x0;
|
static uint16_t _log_flags = 0x0;
|
||||||
|
|
||||||
/* Set to open file to write debug messages directly to file */
|
/* Set to open file to write debug messages directly to file */
|
||||||
static FILE *_log_file = NULL;
|
static FILE *_log_file = NULL;
|
||||||
|
|
@ -148,7 +148,7 @@ int
|
||||||
clixon_log_init(clixon_handle h,
|
clixon_log_init(clixon_handle h,
|
||||||
char *ident,
|
char *ident,
|
||||||
int upto,
|
int upto,
|
||||||
int flags)
|
uint16_t flags)
|
||||||
{
|
{
|
||||||
_log_clixon_h = h;
|
_log_clixon_h = h;
|
||||||
_log_flags = flags;
|
_log_flags = flags;
|
||||||
|
|
@ -222,12 +222,23 @@ clixon_log_file(char *filename)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
/*! Get log flags
|
||||||
clixon_get_logflags(void)
|
*/
|
||||||
|
uint16_t
|
||||||
|
clixon_logflags_get(void)
|
||||||
{
|
{
|
||||||
return _log_flags;
|
return _log_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Replace log flags
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
clixon_logflags_set(uint16_t flags)
|
||||||
|
{
|
||||||
|
_log_flags = flags;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Truncate log/debug string length
|
/*! Truncate log/debug string length
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue