diff --git a/scripts/zmaudit.pl.in b/scripts/zmaudit.pl.in index c467d26e3..afd4881a0 100644 --- a/scripts/zmaudit.pl.in +++ b/scripts/zmaudit.pl.in @@ -409,21 +409,22 @@ MAIN: while( $loop ) { if ( ! $$Storage{Scheme} ) { Error("Storage Scheme not set on $$Storage{Name}"); - if ( ! chdir( $monitor_dir ) ) { - Error( "Can't chdir directory '$$Storage{Path}/$monitor_dir': $!" ); + if ( ! chdir($monitor_dir) ) { + Error("Can't chdir directory '$$Storage{Path}/$monitor_dir': $!"); next; } - if ( ! opendir( DIR, "." ) ) { - Error( "Can't open directory '$$Storage{Path}/$monitor_dir': $!" ); + if ( ! opendir(DIR, '.') ) { + Error("Can't open directory '$$Storage{Path}/$monitor_dir': $!"); next; } - my @temp_events = sort { $b <=> $a } grep { -d $_ && $_ =~ /^\d+$/ } readdir( DIR ); - closedir( DIR ); + my @temp_events = sort { $b <=> $a } grep { -d $_ && $_ =~ /^\d+$/ } readdir(DIR); + closedir(DIR); my $count = 0; foreach my $event ( @temp_events ) { my $Event = $fs_events->{$event} = new ZoneMinder::Event(); $$Event{Id} = $event; #$$Event{Path} = $event_path; + $$Event{Scheme} = 'Shallow'; $Event->MonitorId( $monitor_dir ); $Event->StorageId( $Storage->Id() ); } # end foreach event @@ -570,7 +571,7 @@ MAIN: while( $loop ) { Debug("Database event $$Event{Id} apparently exists at " . $Event->Path() ); } else { if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) { - aud_print( "Database event '$db_monitor/$db_event' does not exist at " . $Event->Path().' in filesystem, deleting' ); + aud_print("Database event '$db_monitor/$db_event' does not exist at " . $Event->Path().' in filesystem, deleting'); if ( confirm() ) { $Event->delete(); $cleaned = 1; @@ -580,7 +581,7 @@ MAIN: while( $loop ) { } } # end if exists in filesystem } else { - Debug("Found fs event for $db_event, $age at " . $$fs_events{$db_event}->Path()); + Debug("Found fs event for id $db_event, $age seconds old at " . $$fs_events{$db_event}->Path()); my $Event = new ZoneMinder::Event( $db_event ); if ( ! $Event->check_for_in_filesystem() ) { Warning("Not found at " . $Event->Path() . ' was found at ' . $$fs_events{$db_event}->Path() ); diff --git a/src/zm.h b/src/zm.h index 092561378..ad0f89584 100644 --- a/src/zm.h +++ b/src/zm.h @@ -17,9 +17,6 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // -#if !defined(PATH_MAX) -#define PATH_MAX 1024 -#endif #ifndef ZM_H #define ZM_H diff --git a/src/zm_comms.h b/src/zm_comms.h index 133c0d19f..e93951a85 100644 --- a/src/zm_comms.h +++ b/src/zm_comms.h @@ -20,6 +20,7 @@ #ifndef ZM_COMMS_H #define ZM_COMMS_H +#include "zm_logger.h" #include "zm_exception.h" #include diff --git a/src/zm_config.h.in b/src/zm_config.h.in index f321095df..87a0f2db4 100644 --- a/src/zm_config.h.in +++ b/src/zm_config.h.in @@ -20,9 +20,11 @@ #ifndef ZM_CONFIG_H #define ZM_CONFIG_H +#if !defined(PATH_MAX) +#define PATH_MAX 1024 +#endif #include "config.h" #include "zm_config_defines.h" -#include "zm.h" #include diff --git a/src/zm_exception.h b/src/zm_exception.h index 83d1ecab1..a02653b88 100644 --- a/src/zm_exception.h +++ b/src/zm_exception.h @@ -20,8 +20,6 @@ #ifndef ZM_EXCEPTION_H #define ZM_EXCEPTION_H -#include "zm.h" - #include class Exception diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index b35e211fd..f9c2029c9 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -43,16 +43,23 @@ void log_libav_callback( void *ptr, int level, const char *fmt, va_list vargs ) log_level = Logger::DEBUG1; } else if ( level == AV_LOG_DEBUG ) { //48 log_level = Logger::DEBUG2; +#ifdef AV_LOG_TRACE } else if ( level == AV_LOG_TRACE ) { log_level = Logger::DEBUG8; +#endif +#ifdef AV_LOG_MAX_OFFSET } else if ( level == AV_LOG_MAX_OFFSET ) { log_level = Logger::DEBUG9; +#endif } else { Error("Unknown log level %d", level); } if ( log ) { - log->logPrint(false, __FILE__, __LINE__, log_level, fmt, vargs); + char logString[8192]; + vsnprintf(logString, sizeof(logString)-1, fmt, vargs); + + log->logPrint(false, __FILE__, __LINE__, log_level, logString); } } diff --git a/src/zm_logger.cpp b/src/zm_logger.cpp index 3ea0c1668..90a2b9aac 100644 --- a/src/zm_logger.cpp +++ b/src/zm_logger.cpp @@ -444,6 +444,7 @@ void Logger::closeSyslog() { void Logger::logPrint( bool hex, const char * const filepath, const int line, const int level, const char *fstring, ... ) { if ( level > mEffectiveLevel ) return; + log_mutex.lock(); char timeString[64]; char logString[8192]; va_list argPtr; @@ -579,6 +580,7 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co abort(); exit(-1); } + log_mutex.unlock(); } diff --git a/src/zm_logger.h b/src/zm_logger.h index 8e2ab6c9d..f65c5ec31 100644 --- a/src/zm_logger.h +++ b/src/zm_logger.h @@ -30,6 +30,8 @@ #endif // HAVE_SYS_SYSCALL_H #include +#include "zm_thread.h" + class Logger { public: enum { @@ -82,6 +84,8 @@ private: static bool smInitialised; static Logger *smInstance; + RecursiveMutex log_mutex; + static StringMap smCodes; static IntMap smSyslogPriorities; diff --git a/src/zm_thread.h b/src/zm_thread.h index 0c41a93a5..8cdfb892c 100644 --- a/src/zm_thread.h +++ b/src/zm_thread.h @@ -20,9 +20,12 @@ #ifndef ZM_THREAD_H #define ZM_THREAD_H +class RecursiveMutex; + + +#include "zm_config.h" #include #include -#include #ifdef HAVE_SYS_SYSCALL_H #include #endif // HAVE_SYS_SYSCALL_H