pnd_log_set_filter ( pndn_rem );
pnd_log_set_pretext ( "pndnotifyd" );
pnd_log_to_stdout();
+ pnd_log_set_flush ( 1 );
pnd_log ( pndn_rem, "log level starting as %u", pnd_log_get_filter() );
}
// pass NULL to free any pre-text, otherwise it'll be kept. Passed in string is duplicated, so you may free yours if you like.
void pnd_log_set_pretext ( char * ); // example: your app-name, or app+function-names, say.
+// after a write, do a flush; may only apply to streams, but will attempt to apply to all
+void pnd_log_set_flush ( unsigned char x );
// set a 'filter level'; any log message of higher-or-equal level than current filter-level will be emitted. Thus, to remove filters
// just set to level 0. Returns existing setting.
char *log_pretext = NULL;
unsigned char log_filterlevel = 0;
+unsigned char log_flushafter = 0;
typedef enum {
pndl_nil = 0,
return ( log_filterlevel );
}
+void pnd_log_set_flush ( unsigned char x ) {
+ log_flushafter = x;
+ return;
+}
+
void pnd_log_set_pretext ( char *pre ) {
if ( log_pretext ) {
if ( strchr ( message, '\n' ) == NULL ) {
fprintf ( log_targets [ i ].stream, "\n" );
}
+ if ( log_flushafter ) {
+ fflush ( log_targets [ i ].stream );
+ }
}
break;