static SemaphoreInfo
*event_semaphore = (SemaphoreInfo *) NULL,
*log_semaphore = (SemaphoreInfo *) NULL;
+
+static MagickBooleanType
+ log_enabled = MagickFalse;
\f
/*
Forward declarations.
LoadLogCache(LinkedListInfo *,const char *,const char *,const size_t,
ExceptionInfo *);
\f
+static void CheckLogEnabled()
+{
+ /* We don't need locks because we only call this inside log_semaphore */
+ if (IsLinkedListEmpty(log_cache) != MagickFalse)
+ log_enabled=MagickFalse;
+ else
+ {
+ LogInfo
+ *p;
+
+ ResetLinkedListIterator(log_cache);
+ p=(LogInfo *) GetNextValueInLinkedList(log_cache);
+ log_enabled=p->event_mask != NoEvents ? MagickTrue: MagickFalse;
+ }
+}
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
ActivateSemaphoreInfo(&log_semaphore);
LockSemaphoreInfo(log_semaphore);
if (log_cache == (LinkedListInfo *) NULL)
- log_cache=AcquireLogCache(LogFilename,exception);
+ {
+ log_cache=AcquireLogCache(LogFilename,exception);
+ CheckLogEnabled();
+ }
UnlockSemaphoreInfo(log_semaphore);
}
return(log_cache != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
*/
MagickExport MagickBooleanType IsEventLogging(void)
{
- const LogInfo
- *log_info;
-
- ExceptionInfo
- *exception;
-
- if ((log_cache == (LinkedListInfo *) NULL) ||
- (IsLinkedListEmpty(log_cache) != MagickFalse))
- return(MagickFalse);
- exception=AcquireExceptionInfo();
- log_info=GetLogInfo("*",exception);
- exception=DestroyExceptionInfo(exception);
- return(log_info->event_mask != NoEvents ? MagickTrue : MagickFalse);
+ return(log_enabled);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LockSemaphoreInfo(log_semaphore);
if (log_cache != (LinkedListInfo *) NULL)
log_cache=DestroyLinkedList(log_cache,DestroyLogElement);
+ log_enabled=MagickFalse;
UnlockSemaphoreInfo(log_semaphore);
RelinquishSemaphoreInfo(&log_semaphore);
}
return(filename);
}
-MagickBooleanType LogMagickEventList(const LogEventType type,const char *module,
- const char *function,const size_t line,const char *format,va_list operands)
+MagickExport MagickBooleanType LogMagickEventList(const LogEventType type,
+ const char *module,const char *function,const size_t line,const char *format,
+ va_list operands)
{
char
event[MagickPathExtent],
LogInfo
*log_info;
- if (IsEventLogging() == MagickFalse)
- return(MagickFalse);
exception=AcquireExceptionInfo();
log_info=(LogInfo *) GetLogInfo("*",exception);
exception=DestroyExceptionInfo(exception);
return(MagickTrue);
}
-MagickBooleanType LogMagickEvent(const LogEventType type,const char *module,
- const char *function,const size_t line,const char *format,...)
+MagickExport MagickBooleanType LogMagickEvent(const LogEventType type,
+ const char *module,const char *function,const size_t line,
+ const char *format,...)
{
va_list
operands;
MagickBooleanType
status;
+ if (IsEventLogging() == MagickFalse)
+ return(MagickFalse);
va_start(operands,format);
status=LogMagickEventList(type,module,function,line,format,operands);
va_end(operands);
log_info->event_mask=(LogEventType) option;
if (option == -1)
log_info->event_mask=UndefinedEvents;
+ CheckLogEnabled();
UnlockSemaphoreInfo(log_semaphore);
return(log_info->event_mask);
}
IsEventLogging(void),
ListLogInfo(FILE *,ExceptionInfo *),
LogMagickEvent(const LogEventType,const char *,const char *,const size_t,
- const char *,...)
- magick_attribute((__format__ (__printf__,5,6))),
+ const char *,...) magick_attribute((__format__ (__printf__,5,6))),
LogMagickEventList(const LogEventType,const char *,const char *,const size_t,
const char *,va_list) magick_attribute((__format__ (__printf__,5,0)));