diff --git a/src/zm_config.cpp b/src/zm_config.cpp index 9c0734e0b..910173fab 100644 --- a/src/zm_config.cpp +++ b/src/zm_config.cpp @@ -69,7 +69,7 @@ void zmLoadConfig() { Debug( 1, "Fetching ZM_SERVER_ID For Name = %s", staticConfig.SERVER_NAME.c_str() ); std::string sql = stringtf("SELECT Id FROM Servers WHERE Name='%s'", staticConfig.SERVER_NAME.c_str() ); - zmDbRow dbrow; + zmDbRow dbrow; if ( dbrow.fetch( sql.c_str() ) ) { staticConfig.SERVER_ID = atoi(dbrow[0]); } else { @@ -81,12 +81,12 @@ void zmLoadConfig() { Debug( 1, "Fetching ZM_SERVER_NAME For Id = %d", staticConfig.SERVER_ID ); std::string sql = stringtf("SELECT Name FROM Servers WHERE Id='%d'", staticConfig.SERVER_ID ); - zmDbRow dbrow; - if ( dbrow.fetch( sql.c_str() ) ) { - staticConfig.SERVER_NAME = std::string(dbrow[0]); - } else { - Fatal("Can't get ServerName for Server ID %d", staticConfig.SERVER_ID ); - } + zmDbRow dbrow; + if ( dbrow.fetch( sql.c_str() ) ) { + staticConfig.SERVER_NAME = std::string(dbrow[0]); + } else { + Fatal("Can't get ServerName for Server ID %d", staticConfig.SERVER_ID ); + } if ( staticConfig.SERVER_ID ) { Debug( 3, "Multi-server configuration detected. Server is %d.", staticConfig.SERVER_ID ); diff --git a/src/zm_logger.cpp b/src/zm_logger.cpp index 32ad7fe61..c172d9132 100644 --- a/src/zm_logger.cpp +++ b/src/zm_logger.cpp @@ -131,16 +131,17 @@ void Logger::initialise( const std::string &id, const Options &options ) { this->id( id ); std::string tempLogFile; - if ( options.mLogPath.size() ) { - mLogPath = options.mLogPath; - tempLogFile = mLogPath+"/"+mId+".log"; - } - if ( options.mLogFile.size() ) - tempLogFile = options.mLogFile; - else - tempLogFile = mLogPath+"/"+mId+".log"; + if ( (envPtr = getTargettedEnv( "LOG_FILE" )) ) tempLogFile = envPtr; + else if ( options.mLogFile.size() ) + tempLogFile = options.mLogFile; + else { + if ( options.mLogPath.size() ) { + mLogPath = options.mLogPath; + } + tempLogFile = mLogPath+"/"+mId+".log"; + } Level tempLevel = INFO; Level tempTermLevel = mTermLevel; @@ -560,7 +561,7 @@ void logInit( const char *name, const Logger::Options &options ) { if ( !Logger::smInstance ) Logger::smInstance = new Logger(); Logger::Options tempOptions = options; - tempOptions.mLogPath = staticConfig.PATH_LOGS.c_str(); + tempOptions.mLogPath = staticConfig.PATH_LOGS; Logger::smInstance->initialise( name, tempOptions ); } diff --git a/src/zm_logger.h b/src/zm_logger.h index 27a998c5f..b88246f1f 100644 --- a/src/zm_logger.h +++ b/src/zm_logger.h @@ -56,8 +56,7 @@ public: typedef std::map StringMap; typedef std::map IntMap; - class Options - { + class Options { public: int mTermLevel; int mDatabaseLevel; @@ -166,8 +165,7 @@ public: } Level level( Level=NOOPT ); - bool debugOn() - { + bool debugOn() { return( mEffectiveLevel >= DEBUG1 ); } @@ -190,20 +188,16 @@ public: void logInit( const char *name, const Logger::Options &options=Logger::Options() ); void logTerm(); -inline const std::string &logId() -{ +inline const std::string &logId() { return( Logger::fetch()->id() ); } -inline Logger::Level logLevel() -{ +inline Logger::Level logLevel() { return( Logger::fetch()->level() ); } -inline void logCapLevel( Logger::Level level ) -{ +inline void logCapLevel( Logger::Level level ) { Logger::fetch()->level( level ); } -inline Logger::Level logDebugging() -{ +inline Logger::Level logDebugging() { return( Logger::fetch()->debugOn() ); } diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 90534a59a..7e8f1863e 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1198,7 +1198,7 @@ bool Monitor::Analyse() { int pending_frames = shared_data->last_write_index - shared_data->last_read_index; if ( pending_frames < 0 ) pending_frames += image_buffer_count; - Debug( 4, "RI:%d, WI: %d, PF = %d, RM = %d, Step = %d", shared_data->last_read_index, shared_data->last_write_index, pending_frames, read_margin, step ); + Debug( 4, "ReadIndex:%d, WriteIndex: %d, PendingFrames = %d, ReadMargin = %d, Step = %d", shared_data->last_read_index, shared_data->last_write_index, pending_frames, read_margin, step ); if ( step <= pending_frames ) { index = (shared_data->last_read_index+step)%image_buffer_count; } else { diff --git a/src/zma.cpp b/src/zma.cpp index e59a0e65d..9f49cdd76 100644 --- a/src/zma.cpp +++ b/src/zma.cpp @@ -57,8 +57,7 @@ behind. #include "zm_signal.h" #include "zm_monitor.h" -void Usage() -{ +void Usage() { fprintf( stderr, "zma -m \n" ); fprintf( stderr, "Options:\n" ); fprintf( stderr, " -m, --monitor : Specify which monitor to use\n" ); @@ -67,8 +66,7 @@ void Usage() exit( 0 ); } -int main( int argc, char *argv[] ) -{ +int main( int argc, char *argv[] ) { self = argv[0]; srand( getpid() * time( 0 ) ); @@ -82,18 +80,15 @@ int main( int argc, char *argv[] ) {0, 0, 0, 0} }; - while (1) - { + while (1) { int option_index = 0; int c = getopt_long (argc, argv, "m:h:v", long_options, &option_index); - if (c == -1) - { + if ( c == -1 ) { break; } - switch (c) - { + switch (c) { case 'm': id = atoi(optarg); break; @@ -110,8 +105,7 @@ int main( int argc, char *argv[] ) } } - if (optind < argc) - { + if (optind < argc) { fprintf( stderr, "Extraneous options, " ); while (optind < argc) printf ("%s ", argv[optind++]); @@ -119,8 +113,7 @@ int main( int argc, char *argv[] ) Usage(); } - if ( id < 0 ) - { + if ( id < 0 ) { fprintf( stderr, "Bogus monitor %d\n", id ); Usage(); exit( 0 ); @@ -137,8 +130,7 @@ int main( int argc, char *argv[] ) Monitor *monitor = Monitor::Load( id, true, Monitor::ANALYSIS ); - if ( monitor ) - { + if ( monitor ) { Info( "In mode %d/%d, warming up", monitor->GetFunction(), monitor->Enabled() ); zmSetDefaultHupHandler(); @@ -154,43 +146,34 @@ int main( int argc, char *argv[] ) monitor->UpdateAdaptiveSkip(); last_analysis_update_time = time( 0 ); - while( !zm_terminate ) - { + while( !zm_terminate ) { // Process the next image sigprocmask( SIG_BLOCK, &block_set, 0 ); // Some periodic updates are required for variable capturing framerate - if ( analysis_update_delay ) - { + if ( analysis_update_delay ) { cur_time = time( 0 ); - if ( (unsigned int)( cur_time - last_analysis_update_time ) > analysis_update_delay ) - { + if ( (unsigned int)( cur_time - last_analysis_update_time ) > analysis_update_delay ) { analysis_rate = monitor->GetAnalysisRate(); monitor->UpdateAdaptiveSkip(); last_analysis_update_time = cur_time; } } - if ( !monitor->Analyse() ) - { + if ( !monitor->Analyse() ) { usleep( monitor->Active()?ZM_SAMPLE_RATE:ZM_SUSPENDED_RATE ); - } - else if ( analysis_rate ) - { + } else if ( analysis_rate ) { usleep( analysis_rate ); } - if ( zm_reload ) - { + if ( zm_reload ) { monitor->Reload(); zm_reload = false; } sigprocmask( SIG_UNBLOCK, &block_set, 0 ); } delete monitor; - } - else - { + } else { fprintf( stderr, "Can't find monitor with id of %d\n", id ); } Image::Deinitialise(); diff --git a/web/includes/Event.php b/web/includes/Event.php index 3a504145c..857059efc 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -48,10 +48,16 @@ class Event { } public function __call( $fn, array $args){ + if ( count( $args ) ) { + $this->{$fn} = $args[0]; + } if ( array_key_exists( $fn, $this ) ) { return $this->{$fn}; -#array_unshift($args, $this); -#call_user_func_array( $this->{$fn}, $args); + + $backTrace = debug_backtrace(); + $file = $backTrace[1]['file']; + $line = $backTrace[1]['line']; + Warning( "Unknown function call Event->$fn from $file:$line" ); } } diff --git a/web/includes/Frame.php b/web/includes/Frame.php index b875ad113..7575aeed8 100644 --- a/web/includes/Frame.php +++ b/web/includes/Frame.php @@ -36,10 +36,16 @@ class Frame { return new Event( $this->{'EventId'} ); } public function __call( $fn, array $args){ - if( array_key_exists( $fn, $this ) ) { + if ( count( $args ) ) { + $this->{$fn} = $args[0]; + } + if ( array_key_exists( $fn, $this ) ) { return $this->{$fn}; -#array_unshift($args, $this); -#call_user_func_array( $this->{$fn}, $args); + + $backTrace = debug_backtrace(); + $file = $backTrace[1]['file']; + $line = $backTrace[1]['line']; + Warning( "Unknown function call Frame->$fn from $file:$line" ); } } diff --git a/web/includes/Storage.php b/web/includes/Storage.php index d03f089f0..84949e988 100644 --- a/web/includes/Storage.php +++ b/web/includes/Storage.php @@ -58,10 +58,16 @@ class Storage { } public function __call( $fn, array $args= NULL){ - if(isset($this->{$fn})){ + if ( count( $args ) ) { + $this->{$fn} = $args[0]; + } + if ( array_key_exists( $fn, $this ) ) { return $this->{$fn}; -#array_unshift($args, $this); -#call_user_func_array( $this->{$fn}, $args); + + $backTrace = debug_backtrace(); + $file = $backTrace[1]['file']; + $line = $backTrace[1]['line']; + Warning( "Unknown function call Storage->$fn from $file:$line" ); } } public static function find_all() { diff --git a/web/includes/database.php b/web/includes/database.php index d19bc86ac..76df214d8 100644 --- a/web/includes/database.php +++ b/web/includes/database.php @@ -127,10 +127,10 @@ function dbQuery( $sql, $params=NULL ) { } else { $result = $dbConn->query( $sql ); } - //if ( $params ) - //Warning("SQL: $sql" . implode(',',$params)); - //else - //Warning("SQL: $sql" ); + if ( $params ) + Warning("SQL: $sql" . implode(',',$params)); + else + Warning("SQL: $sql" ); } catch(PDOException $e) { Error( "SQL-ERR '".$e->getMessage()."', statement was '".$sql."' params:" . implode(',',$params) ); } diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 82e668111..9cae836ce 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -48,11 +48,13 @@ function xhtmlHeaders( $file, $title ) { <?php echo ZM_WEB_TITLE_PREFIX ?> - <?php echo validHtmlStr($title) ?> "; - echo ""; + echo "\n"; + echo "\n"; } else { - echo ''; - echo ''; + echo ' + + +'; } ?> @@ -107,6 +109,7 @@ if ( file_exists( "skins/$skin/css/$css/graphics/favicon.ico" ) ) {