Fixed a bug where clicon_debug_init interfered with clicon_log_file
This commit is contained in:
parent
c269d094e4
commit
d914495ab4
1 changed files with 11 additions and 7 deletions
|
|
@ -71,7 +71,6 @@ static int _logflags = 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 *_logfile = NULL;
|
static FILE *_logfile = NULL;
|
||||||
|
|
||||||
|
|
||||||
/*! Initialize system logger.
|
/*! Initialize system logger.
|
||||||
*
|
*
|
||||||
* Make syslog(3) calls with specified ident and gates calls of level upto specified level (upto).
|
* Make syslog(3) calls with specified ident and gates calls of level upto specified level (upto).
|
||||||
|
|
@ -144,6 +143,7 @@ clicon_log_opt(char c)
|
||||||
* @param[in] filename File to log to
|
* @param[in] filename File to log to
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
|
* @see clicon_debug_init where a strean
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clicon_log_file(char *filename)
|
clicon_log_file(char *filename)
|
||||||
|
|
@ -236,9 +236,7 @@ clicon_log_str(int level,
|
||||||
flogtime(_logfile);
|
flogtime(_logfile);
|
||||||
fprintf(_logfile, "%s\n", msg);
|
fprintf(_logfile, "%s\n", msg);
|
||||||
fflush(_logfile);
|
fflush(_logfile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable this if you want syslog in a stream. But there are problems with
|
/* Enable this if you want syslog in a stream. But there are problems with
|
||||||
* recursion
|
* recursion
|
||||||
*/
|
*/
|
||||||
|
|
@ -305,17 +303,23 @@ clicon_log(int level,
|
||||||
* debugging.
|
* debugging.
|
||||||
*
|
*
|
||||||
* @param[in] dbglevel 0 is show no debug messages, 1 is normal, 2.. is high debug.
|
* @param[in] dbglevel 0 is show no debug messages, 1 is normal, 2.. is high debug.
|
||||||
Note this is _not_ level from syslog(3)
|
* Note this is _not_ level from syslog(3)
|
||||||
* @param[in] f Debug-file. Open file where debug messages are directed.
|
* @param[in] f Debug-file. Open file where debug messages are directed.
|
||||||
This overrides the clicon_log settings which is otherwise where
|
* If not NULL, it overrides the clicon_log settings which is otherwise
|
||||||
debug messages are directed.
|
* where debug messages are directed.
|
||||||
|
* @see clicon_log_file where a filename can be given
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clicon_debug_init(int dbglevel,
|
clicon_debug_init(int dbglevel,
|
||||||
FILE *f)
|
FILE *f)
|
||||||
{
|
{
|
||||||
_clixon_debug = dbglevel; /* Global variable */
|
_clixon_debug = dbglevel; /* Global variable */
|
||||||
_logfile = f;
|
|
||||||
|
if (f != NULL){
|
||||||
|
if (_logfile)
|
||||||
|
fclose(_logfile);
|
||||||
|
_logfile = f;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue