66 .
synopsis =
"Example of librnr logging and options processing facilities.",
69 "The %P command demonstrates various macros and functions of the " 70 "librnr logging facilities, plus command-line options processing." 82 .has_arg = required_argument,
89 "Set the logging test(s) to conduct.\n" 112 double f,
int hex,
bool_t bAreRipe)
121 LOGDIAG2(
"There are %d juicy %s in %s", n, sFruit,
"Tuscany");
125 LOGDIAG2(
"There are %d green %s in %s", n, sFruit,
"Utah");
137 const char *sFileName =
"PackingShedOnStrike.newsflash";
142 LOGWARN(
"Ebola is your friend, Mr. %s.",
"Sicko");
147 LOGERROR(
"Salmonella scare %d...", count);
151 if( (fp = fopen(sFileName,
"r")) ==
NULL )
157 LOGDIAG4(
"%s: what a pleasant surprise", sFileName);
177 logtest_num1(&i,
"apples", 53, h, 123.5, 0xdead,
false);
201 static int init(
int argc,
char *argv[])
207 Argv0 = basename(argv[0]);
219 LOGDIAG1(
"Post options processed non-option arguments:");
221 for(i=0; i<argc; ++i)
223 fprintf(fp,
" argv[%d]=\"%s\"\n", i, argv[i]);
239 int main(
int argc,
char *argv[])
241 printf(
"arch : %s\n", ARCH);
243 if( !
init(argc, argv) )
#define _THEX(var)
int (hex)
#define CHKEXPR_INT(val, expr,...)
check integer
#define _TINT(var)
int (decimal)
FILE * LOG_GET_LOGFP()
Get current logging output stream file pointer.
static OptsInfo_T LogExampleOptsInfo[]
Command line options information.
Standard command-line options options and parsing.
Program Description Strings Info Structure.
int main(int argc, char *argv[])
Example main.
static void logtest_num2(int count)
Log test number 2.
char * OptsFmtInt(char *buf, size_t buflen, void *pOptVal)
Integer option value string formatter.
#define _TSHORT(var)
short int (decimal)
#define LOGDIAG1(fmt,...)
Standard Diagnostic Level 1 logging.
static int OptsTest
test option value
static void logtest_num1(void *p, const char *sFruit, int n, int half, double f, int hex, bool_t bAreRipe)
Log test number 1.
#define LOGSYSERROR(fmt,...)
Standard System Error logging.
const char * synopsis
Simple program synopsis string.
#define LOGDIAG2(fmt,...)
Standard Diagnostic Level 2 logging.
#define LOGERROR(fmt,...)
Standard Error logging.
#define LOGABLE(level)
Test if given level is logable at current threshold.
int OptsCvtArgInt(const char *argv0, const char *sOptName, char *optarg, void *pOptVal)
Convert options integer argument to integer.
#define LOGWARN(fmt,...)
Standard Warning logging.
#define LOGDIAG4(fmt,...)
Standard Diagnostic Level 4 logging.
static int runlogtests()
Run log test(s).
static const PkgInfo_T PkgInfo
RoadNarrows Robotics common configuration file.
char ** OptsGet(const char *argv0, const PkgInfo_T *pPkgInfo, OptsPgmInfo_T *pPgmInfo, OptsInfo_T *pOptsInfo, bool_t bHasLogging, int *pargc, char *argv[])
Gets, validates, and sets all command line options.
#define _TBOOL(var)
boolean
Package version information.
#define _TSTR(var)
string variable
#define LOG_LEVEL_DIAG1
diagnostic level 1
static OptsPgmInfo_T LogExamplePgmInfo
Program information.
#define _TPTR(var)
pointer
#define _TFLOAT(var)
float
static char * Argv0
the command
const char * long_opt
Long option string name.
#define LOGDIAG2CALL(...)
Standard Diagnostic Level 2 function call tracing.
Short and Long Options Info.
#define LOGDIAG1CALL(...)
Standard Diagnostic Level 1 function call tracing.
static int init(int argc, char *argv[])
Main initialization.