![]() |
librnr
1.14.5
RoadNarrows Robotics Common Library 1
|
Logger definitions. More...
#include <stdio.h>#include <stdarg.h>#include <time.h>#include <string.h>#include <pthread.h>#include "rnr/rnrconfig.h"#include "rnr/log.h"#include "rnr/new.h"Go to the source code of this file.
Macros | |
| #define | LOG_VAR_FILENAME LOGNS_PUT(LogFileName) |
| define in namespace | |
| #define | LOG_VAR_FP LOGNS_PUT(LogFp) |
| define in namespace | |
Functions | |
| static const char * | LOGNS_PUT (LogFileName) |
| Log File Name. | |
| static FILE * | LOGNS_PUT (LogFp) |
| Opened Log file. | |
| int | LOG_SET_THRESHOLD (int nLevel) |
| Set new logging threshold level. More... | |
| int | LOG_GET_THRESHOLD () |
| Get current logging threshold level. More... | |
| void | LOG_SET_COLOR_ENABLE (bool_t enable) |
| Enable/disable logging in color. More... | |
| void | LOG_SET_TIMESTAMP_ENABLE (bool_t enable) |
| Enable/disable log timestamps. More... | |
| int | LOG_SET_LOGFILE (const char *sLogFileName) |
| Set new logging output file. More... | |
| const char * | LOG_GET_LOGFILE () |
| Get logging output stream file name. More... | |
| void | LOG_ATTACH_LOGFP (FILE *fp, const char *sFpFileName) |
| Attach opened file pointer as the new logging output stream. More... | |
| FILE * | LOG_GET_LOGFP () |
| Get current logging output stream file pointer. More... | |
| void | LOGGER (const char *sFmt,...) |
| Print loggging diagnostics, debug, error, and system error messages to log output stream.. More... | |
| static int | LogVaFmtType (char *sFmt) |
| Parse function call argument format string to determine type. More... | |
| void | LOGGER_CALL (const char *sPreface, int nLevel, const char *sFile, int nLine, const char *sFuncName,...) |
| Print function call diagnostics tracing to log output stream.. More... | |
Variables | |
| int | LOG_VAR_THRESHOLD = LOG_LEVEL_DFT |
| Log threshold level (log iff level <= threshold) | |
| bool_t | LOG_VAR_COLOR_EN = LOG_COLOR_EN_DFT |
| Log in color (false = disable, true = enable) | |
| static bool_t | LOG_VAR_TIMESTAMP_EN = LOG_TIMESTAMP_EN_DFT |
| Timestamp logging (false = disable, true = enable) | |
| static pthread_mutex_t | MutexLog = PTHREAD_MUTEX_INITIALIZER |
Logger definitions.
Logging supports error and diagnostics (debugging) reports to stderr or a specified file. Logging reporting is filtered by a simple threshold level.
Definition in file log.c.
| void LOG_ATTACH_LOGFP | ( | FILE * | fp, |
| const char * | sFpFileName | ||
| ) |
Attach opened file pointer as the new logging output stream.
Actual Identifier: <LOGNS>LogAttachLogFp()
| fp | Opened FILE*. |
| sFpFileName | File name associated with fp. |
Definition at line 282 of file log.c.
References LOG_VAR_FILENAME, LOG_VAR_FP, and new_strdup().
| const char* LOG_GET_LOGFILE | ( | ) |
Get logging output stream file name.
Actual Identifier: <LOGNS>LogGetFileName()
Definition at line 260 of file log.c.
References LOG_FILENAME_DFT, LOG_VAR_FILENAME, and NULL.
| FILE* LOG_GET_LOGFP | ( | ) |
Get current logging output stream file pointer.
This function is handing if an application has some complicated output for the logging stream.
Actual Identifier: <LOGNS>LogGetLogFp()
Definition at line 301 of file log.c.
References LOG_VAR_FP.
Referenced by init(), and NewSearchPathDList().
| int LOG_GET_THRESHOLD | ( | ) |
Get current logging threshold level.
This function is always defined to safeley determine if logging is available.
Actual Identifier: <LOGNS>LogGetThresholdLevel()
Definition at line 142 of file log.c.
References LOG_VAR_THRESHOLD, and LOGGING_NA.
| void LOG_SET_COLOR_ENABLE | ( | bool_t | enable | ) |
Enable/disable logging in color.
This function is always defined to allow blind sets.
Actual Identifier: <LOGNS>LogSetColorEnable()
| enable | Enable(true) or disable(false). |
Definition at line 160 of file log.c.
References LOG_VAR_COLOR_EN.
Referenced by OptsLogDisableColor().
| int LOG_SET_LOGFILE | ( | const char * | sLogFileName | ) |
Set new logging output file.
The file is opened and truncated.
This function is always defined allow blind sets.
Actual Identifier: <LOGNS>LogSetLogFile()
| sLogFileName | Name of new log file. |
Definition at line 199 of file log.c.
References LOG_FILENAME_STDERR, LOG_FILENAME_STDOUT, LOG_VAR_FILENAME, LOG_VAR_FP, LOGDIAG1, LOGSYSERROR, new_strdup(), and NULL.
Referenced by OptsLogSetFile().
| int LOG_SET_THRESHOLD | ( | int | nLevel | ) |
Set new logging threshold level.
All logging at the level <= threshold level will be enabled.
This function is always defined allow blind sets.
Actual Identifier: <LOGNS>LogSetThresholdLevel()
| nLevel | New threshold level. |
Definition at line 96 of file log.c.
References LOG_LEVEL_DIAG1, LOG_LEVEL_OFF, LOG_VAR_COLOR_EN, LOG_VAR_THRESHOLD, LOGARGS_DIAG, LOGARGS_DIAG_PLAIN, LOGGER(), and LOGGING_NA.
Referenced by CmdLog(), main(), and OptsLogSetLevel().
| void LOG_SET_TIMESTAMP_ENABLE | ( | bool_t | enable | ) |
Enable/disable log timestamps.
This function is always defined to allow blind sets.
Actual Identifier: <LOGNS>LogSetTimestampEnable()
| enable | Enable(true) or disable(false). |
Definition at line 176 of file log.c.
References LOG_VAR_TIMESTAMP_EN.
Referenced by OptsLogDisableTimestamp().
| void LOGGER | ( | const char * | sFmt, |
| ... | |||
| ) |
Print loggging diagnostics, debug, error, and system error messages to log output stream..
Actual Identifier: <LOGNS>LogPrintf()
| sFmt | Format string. |
| ... | Variable format arguments. |
Definition at line 317 of file log.c.
References LOG_FILENAME_STDERR, LOG_FP_DFT, LOG_VAR_FILENAME, LOG_VAR_FP, LOG_WITH_TIMESTAMP, new_strdup(), and NULL.
Referenced by LOG_SET_THRESHOLD().
| void LOGGER_CALL | ( | const char * | sPreface, |
| int | nLevel, | ||
| const char * | sFile, | ||
| int | nLine, | ||
| const char * | sFuncName, | ||
| ... | |||
| ) |
Print function call diagnostics tracing to log output stream..
Actual Identifier: <LOGNS>LogCallPrintf()
| sPreface | Logging preface string. |
| nLevel | Logging level. |
| sFile | File holding function definition. |
| nLine | File line number. |
| sFuncName | Function name string. |
| ... | Pairs of function format_string,argument pairs terminated by NULL,0 |
Definition at line 445 of file log.c.
References LOG_COLOR_DIAG, LOG_COLOR_POST, LOG_FILENAME_STDERR, LOG_FP_DFT, LOG_VAR_FILENAME, LOG_VAR_FP, LOG_WITH_TIMESTAMP, LogColorEnable, LogVaFmtType(), new_strdup(), and NULL.
|
static |
Parse function call argument format string to determine type.
Type range is determined by what va_arg() takes.
| sFmt | Argument format string. |
Definition at line 359 of file log.c.
Referenced by LOGGER_CALL().