-- but now you can just add -l to command line to cause it to go go debuglevel and spit out to /tmp/pndnotifyd.log
-- can actualyl do -l#, where # is log level, default is 0 (all)
pnd_logger now has set_buried_logging() which lets you turn on logging in libpnd API that doesn't normally log, such as
the discovery code; this way we can log some deep-shit, if we really want to
XMLOBJ = lib/tinyxml/tinystr.o lib/tinyxml/tinyxml.o lib/tinyxml/tinyxmlerror.o lib/tinyxml/tinyxmlparser.o
ALLOBJ = pnd_conf.o pnd_container.o pnd_discovery.o pnd_pxml.o pnd_notify.o pnd_locate.o pnd_tinyxml.o pnd_pndfiles.o pnd_apps.o pnd_utility.o pnd_desktop.o pnd_io_gpio.o pnd_logger.o
-all: ${SOLIB} ${LIB} conftest discotest notifytest pndnotifyd rawpxmltest pndvalidator loggertest pnd_run pndevmapperd
+all: ${SOLIB} ${LIB} conftest discotest notifytest pndnotifyd rawpxmltest pndvalidator loggertest pnd_run pndevmapperd pnd_info
clean:
- ${RM} -f ${ALLOBJ} ${XMLOBJ} ${LIB} ${SOLIB1} locatetest.o bin/locatetest conftest.o bin/conftest discotest.o bin/discotest loggertest.o bin/loggertest bin/notifytest notifytest.o bin/rawpxmltest rawpxmltest.o bin/pnd_run pnd_run.o bin/pndevmapperd pndevmapperd.o bin/pndnotifyd pndnotifyd.o ${SOLIB} testdata/dotdesktop/*.desktop testdata/menu/*.desktop testdata/apps/*.pnd testdata/dotdesktop/*.png deployment/usr/lib/libpnd* deployment/usr/bin/pndnotifyd deployment/usr/bin/pnd_run deployment/usr/pandora/scripts/* deployment/etc/sudoers deployment/etc/init.d/pndnotifyd bin/pndvalidator pndvalidator.o deployment/usr/bin/pndevmapperd testdata/menuicons/*
+ ${RM} -f ${ALLOBJ} ${XMLOBJ} ${LIB} ${SOLIB1} locatetest.o bin/locatetest conftest.o bin/conftest discotest.o bin/discotest loggertest.o bin/loggertest bin/notifytest notifytest.o bin/rawpxmltest rawpxmltest.o bin/pnd_run pnd_run.o pnd_info.o bin/pnd_info bin/pndevmapperd pndevmapperd.o bin/pndnotifyd pndnotifyd.o ${SOLIB} testdata/dotdesktop/*.desktop testdata/menu/*.desktop testdata/apps/*.pnd testdata/dotdesktop/*.png deployment/usr/lib/libpnd* deployment/usr/bin/pndnotifyd deployment/usr/bin/pnd_run deployment/usr/bin/pnd_info deployment/usr/pandora/scripts/* deployment/etc/sudoers deployment/etc/init.d/pndnotifyd bin/pndvalidator pndvalidator.o deployment/usr/bin/pndevmapperd testdata/menuicons/*
${RM} -rf deployment/media
find . -name "*~*" -exec rm {} \; -print
pnd_run: pnd_run.o ${SOLIB1}
${CC} -lstdc++ -o bin/pnd_run pnd_run.o ${SOLIB1}
+pnd_info: pnd_info.o ${SOLIB1}
+ ${CC} -lstdc++ -o bin/pnd_info pnd_info.o ${SOLIB1}
+
pndevmapperd: pndevmapperd.o ${SOLIB1}
${CC} -lstdc++ -o bin/pndevmapperd pndevmapperd.o ${SOLIB1}
// behaviour
unsigned char scanonlaunch = 1;
unsigned int interval_secs = 5;
+ int logall = -1; // -1 means normal logging rules; >=0 means log all!
// misc
int i;
interval_secs = atoi ( argv [ i ] );
} else if ( argv [ i ][ 0 ] == '-' && argv [ i ][ 1 ] == 'n' ) {
scanonlaunch = 0;
+ } else if ( argv [ i ][ 0 ] == '-' && argv [ i ][ 1 ] == 'l' ) {
+
+ if ( isdigit ( argv [ i ][ 2 ] ) ) {
+ unsigned char x = atoi ( argv [ i ] + 2 );
+ if ( x >= 0 &&
+ x < pndn_none )
+ {
+ logall = x;
+ }
+ } else {
+ logall = 0;
+ }
+
} else {
printf ( "%s [-d] [##]\n", argv [ 0 ] );
printf ( "-d\tDaemon mode; detach from terminal, chdir to /tmp, suppress output. Optional.\n" );
printf ( "-n\tDo not scan on launch; default is to run a scan for apps when %s is invoked.\n", argv [ 0 ] );
+ printf ( "-l#\tLog-it; -l is 0-and-up (or all), and -l2 means 2-and-up (not all); l[0-3] for now. Log goes to /tmp/pndnotifyd.log\n" );
printf ( "##\tA numeric value is interpreted as number of seconds between checking for filesystem changes. Default %u.\n",
interval_secs );
printf ( "Signal: HUP the process to force reload of configuration and reset the notifier watch paths\n" );
/* enable logging?
*/
- if ( g_daemon_mode ) {
- // nada
+ pnd_log_set_pretext ( "pndnotifyd" );
+ pnd_log_set_flush ( 1 );
+
+ if ( logall == -1 ) {
+ // standard logging; non-daemon versus daemon
+
+ if ( g_daemon_mode ) {
+ // nada
+ } else {
+ pnd_log_set_filter ( pndn_rem );
+ pnd_log_to_stdout();
+ }
+
} else {
- 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() );
- }
+ FILE *f;
+
+ f = fopen ( "/tmp/pndnotifyd.log", "w" );
+
+ if ( f ) {
+ pnd_log_set_filter ( logall );
+ pnd_log_to_stream ( f );
+ pnd_log ( pndn_rem, "logall mode - logging to /tmp/pndnotifyd.log\n" );
+ }
+
+ if ( logall == pndn_debug ) {
+ pnd_log_set_buried_logging ( 1 ); // log the shit out of it
+ pnd_log ( pndn_rem, "logall mode 0 - turned on buried logging\n" );
+ }
+
+ } // logall
+
+ pnd_log ( pndn_rem, "log level starting as %u", pnd_log_get_filter() );
pnd_log ( pndn_rem, "Interval between checks is %u seconds\n", interval_secs );
}
if ( pnd_conf_get_as_int ( apph, PNDNOTIFYD_LOGLEVEL ) != PND_CONF_BADNUM ) {
- pnd_log_set_filter ( pnd_conf_get_as_int ( apph, PNDNOTIFYD_LOGLEVEL ) );
- pnd_log ( pndn_rem, "config file causes loglevel to change to %u", pnd_log_get_filter() );
+ if ( pnd_log_do_buried_logging() == 0 ) {
+ pnd_log_set_filter ( pnd_conf_get_as_int ( apph, PNDNOTIFYD_LOGLEVEL ) );
+ pnd_log ( pndn_rem, "config file causes loglevel to change to %u", pnd_log_get_filter() );
+ } else {
+ pnd_log ( pndn_rem, "-l command line suppresses log level change in config file\n" );
+ }
}
} else {
{
pnd_box_handle applist;
+ pnd_log ( pndn_rem, "perform discovery - apps: %s, overrides: %s\n", appspath, overridespath );
+ pnd_log ( pndn_rem, " - emit desktop: %s, icons: %s\n", emitdesktoppath, emiticonpath );
+
// attempt to auto-discover applications in the given path
applist = pnd_disco_search ( appspath, overridespath );
}
}
if ( source_libpnd ) {
-#if 0
- pnd_log ( pndn_rem,
+#if 1
+ pnd_log ( pndn_debug,
"File '%s' appears to have been created by libpnd so candidate for delete: %u\n", buffer, source_libpnd );
#endif
} else {
-#if 0
- pnd_log ( pndn_rem, "File '%s' appears NOT to have been created by libpnd, so leave it alone\n", buffer );
+#if 1
+ pnd_log ( pndn_debug, "File '%s' appears NOT to have been created by libpnd, so leave it alone\n", buffer );
#endif
continue; // skip deleting it
}
// file is 'new'?
if ( stat ( buffer, &dirs ) == 0 ) {
if ( dirs.st_mtime >= createtime ) {
-#if 0
- pnd_log ( pndn_rem, "File '%s' seems 'new', so leave it alone.\n", buffer );
+#if 1
+ pnd_log ( pndn_debug, "File '%s' seems 'new', so leave it alone.\n", buffer );
#endif
continue; // skip deleting it
}
// how many targets can be opened, entirely? this is a compile time limit, for sanity.
unsigned char pnd_log_max_targets ( void );
+// tell buried lib functions to do some logging here; ie: since not all API's have a 'options' type flag where we could
+// add a hint to begin logging, they can just ask the logger if they need to do it
+#define PND_LOG_DEFAULT 0 // level 0 is by default the 'debug' level, with anything higher non-debug; only used for buried logging
+void pnd_log_set_buried_logging ( unsigned char yesno ); // set 1 for 'yes', 0 for 'no'
+unsigned char pnd_log_do_buried_logging ( void ); // return 1 for 'yes'
+
#ifdef __cplusplus
} /* "C" */
#endif
#include "pnd_pathiter.h"
#include "pnd_apps.h"
#include "pnd_pndfiles.h"
+#include "pnd_logger.h"
// need these 'globals' due to the way nftw and ftw work :/
static pnd_box_handle disco_box;
unsigned char valid = pnd_object_type_unknown;
pnd_pxml_handle pxmlh = 0;
unsigned int pxml_close_pos = 0;
+ unsigned char logit = pnd_log_do_buried_logging();
- //printf ( "disco root callback encountered '%s'\n", fpath );
+ if ( logit ) {
+ pnd_log ( PND_LOG_DEFAULT, "disco callback encountered '%s'\n", fpath );
+ }
// PXML.xml is a possible application candidate (and not a dir named PXML.xml :)
if ( typeflag & FTW_D ) {
- //printf ( " .. is dir, skipping\n" );
+ if ( logit ) {
+ pnd_log ( PND_LOG_DEFAULT, " .. is dir, skipping\n" );
+ }
return ( 0 ); // skip directories and other non-regular files
}
// if not a file of interest, just keep looking until we run out
if ( ! valid ) {
- //printf ( " .. bad filename, skipping\n" );
+ if ( logit ) {
+ pnd_log ( PND_LOG_DEFAULT, " .. bad filename, skipping\n" );
+ }
return ( 0 );
}
return ( PND_LOG_MAX );
}
-void pnd_log_emit ( char *message ) {
+static void pnd_log_emit ( unsigned char level, char *message ) {
unsigned char i;
// iterate across targets and attempt to emit
break;
case pndl_stream:
+ // pretext
if ( log_pretext ) {
fprintf ( log_targets [ i ].stream, "%s\t", log_pretext );
}
+ // log level
+ fprintf ( log_targets [ i ].stream, "%u\t", level );
+ // message
if ( message ) {
fprintf ( log_targets [ i ].stream, "%s", message );
if ( strchr ( message, '\n' ) == NULL ) {
/* If that worked, return the string. */
if ( n > -1 && n < size ) {
- pnd_log_emit ( p );
+ pnd_log_emit ( level, p );
break;
}
return ( 1 );
}
+
+
+static unsigned char _do_buried_logging = 0;
+void pnd_log_set_buried_logging ( unsigned char yesno ) {
+ _do_buried_logging = yesno;
+ return;
+}
+
+unsigned char pnd_log_do_buried_logging ( void ) {
+ if ( _do_buried_logging == 1 ) {
+ return ( 1 );
+ }
+ return ( 0 );
+}
char *s = freeable_buffer;
char *home = getenv ( "HOME" );
- printf ( "DEBUG: expand tilde IN: '%s'\n", freeable_buffer );
- printf ( "DEBUG: $HOME was %s\n", home );
+ //printf ( "DEBUG: expand tilde IN: '%s'\n", freeable_buffer );
+ //printf ( "DEBUG: $HOME was %s\n", home );
// well, as pndnotifyd (etc) may be running as _root_, while the user is logged in
// as 'pandora' or god knows what, this could be problematic. Other parts of the lib
florp = strdup ( pw -> pw_dir );
home = florp;
- printf ( " DEBUG: home (for %s) is %s (from %u)\n", b.ut_user, home, b.ut_type );
+ //printf ( " DEBUG: home (for %s) is %s (from %u)\n", b.ut_user, home, b.ut_type );
} // passwd entry matches the utmp entry
return ( s ); // can't succeed
}
- printf ( "DEBUG: entering while (%s) with home (%s)\n", s, home );
+ //printf ( "DEBUG: entering while (%s) with home (%s)\n", s, home );
while ( ( p = strchr ( s, '~' ) ) ) {
- printf ( "DEBUG: within while (%s)\n", s );
+ //printf ( "DEBUG: within while (%s)\n", s );
char *temp = malloc ( strlen ( s ) + strlen ( home ) + 1 );
memset ( temp, '\0', strlen ( s ) + strlen ( home ) + 1 );
// copy in stuff prior to ~
s = temp;
} // while finding matches
- printf ( "DEBUG: expand tilde OUT: '%s'\n", s );
+ //printf ( "DEBUG: expand tilde OUT: '%s'\n", s );
return ( s );
}