Data Structures | Defines | Typedefs | Enumerations | Functions | Variables

# log.c File Reference

`#include "wizard/studio.h"`
`#include "wizard/blob.h"`
`#include "wizard/client.h"`
`#include "wizard/configure.h"`
`#include "wizard/exception.h"`
`#include "wizard/exception-private.h"`
`#include "wizard/hashmap.h"`
`#include "wizard/log.h"`
`#include "wizard/memory_.h"`
`#include "wizard/option.h"`
`#include "wizard/semaphore.h"`
`#include "wizard/string_.h"`
`#include "wizard/string-private.h"`
`#include "wizard/thread_.h"`
`#include "wizard/thread-private.h"`
`#include "wizard/timer.h"`
`#include "wizard/token.h"`
`#include "wizard/utility.h"`
`#include "wizard/version.h"`
`#include "wizard/xml-tree.h"`

## Data Structures
struct | _EventInfo
struct | _HandlerInfo
struct | _LogInfo
struct | _LogMapInfo
## Defines
#define | LogFilename "log.xml"
#define | MegabytesToBytes(value) ((WizardSizeType) (value)*1024*1024)
## Typedefs
typedef struct _EventInfo | EventInfo
typedef struct _HandlerInfo | HandlerInfo
typedef struct _LogMapInfo | LogMapInfo
## Enumerations
enum | LogHandlerType { UndefinedHandler = 0x0000, NoHandler = 0x0000, ConsoleHandler = 0x0001, StdoutHandler = 0x0002, StderrHandler = 0x0004, FileHandler = 0x0008, DebugHandler = 0x0010, EventHandler = 0x0020 }
## Functions
static LogHandlerType | ParseLogHandlers (const char *)
static WizardBooleanType | InitializeLogList (ExceptionInfo *)
static WizardBooleanType | LoadLogLists (const char *, ExceptionInfo *)
WizardExport void | CloseWizardLog (void)
WizardExport const LogInfo * | GetLogInfo (const char *name, ExceptionInfo *exception)
static int | LogInfoCompare (const void *x, const void *y)
WizardExport const LogInfo ** | GetLogInfoList (const char *pattern, size_t *number_preferences, ExceptionInfo *exception)
static int | LogCompare (const void *x, const void *y)
WizardExport char ** | GetLogList (const char *pattern, size_t *number_preferences, ExceptionInfo *exception)
WizardExport const char * | GetLogName (void)
WizardExport WizardBooleanType | IsEventLogging (void)
WizardExport WizardBooleanType | ListLogInfo (FILE *file, ExceptionInfo *exception)
WizardExport WizardBooleanType | LogComponentGenesis (void)
static void * | DestroyLogElement (void *log_info)
WizardExport void | LogComponentTerminus (void)
static char * | TranslateEvent (const LogEventType wizard_unused(type), const char *module, const char *function, const size_t line, const char *domain, const char *event)
static char * | TranslateFilename (const LogInfo *log_info)
WizardBooleanType | LogWizardEventList (const LogEventType type, const char *module, const char *function, const size_t line, const char *format, va_list operands)
WizardBooleanType | LogWizardEvent (const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
static WizardBooleanType | LoadLogList (const char *xml, const char *filename, const size_t depth, ExceptionInfo *exception)
WizardExport LogEventType | SetLogEventMask (const char *events)
WizardExport void | SetLogFormat (const char *format)
WizardExport const char * | SetLogName (const char *name)
## Variables
static const HandlerInfo | LogHandlers []
static const LogMapInfo | LogMap []
static char | log_name [MaxTextExtent] = "Wizard"
static LinkedListInfo * | log_list = (LinkedListInfo *) NULL
static SemaphoreInfo * | log_semaphore = (SemaphoreInfo *) NULL
static volatile WizardBooleanType | instantiate_log = WizardFalse

## Define Documentation

#define LogFilename "log.xml"

Referenced by InitializeLogList().

#define MegabytesToBytes | ( |  | value | ) | ((WizardSizeType) (value)*1024*1024)

Referenced by ListLogInfo().

## Typedef Documentation

typedef struct _EventInfo EventInfo

typedef struct _HandlerInfo HandlerInfo

typedef struct _LogMapInfo LogMapInfo

## Enumeration Type Documentation

enum LogHandlerType

Enumerator:

  UndefinedHandler |
  NoHandler |
  ConsoleHandler |
  StdoutHandler |
  StderrHandler |
  FileHandler |
  DebugHandler |
  EventHandler |

## Function Documentation

WizardExport void CloseWizardLog | ( | void |  | ) |

References AcquireExceptionInfo(), _LogInfo::append, DestroyExceptionInfo(), _LogInfo::file, GetLogInfo(), IsEventLogging(), LockSemaphoreInfo(), log_semaphore, UnlockSemaphoreInfo(), and WizardFalse.

static void* DestroyLogElement | ( | void * | log_info | ) | `[static]`

References _LogInfo::append, DestroyString(), DestroyTimerInfo(), _LogInfo::exempt, _LogInfo::file, _LogInfo::filename, _LogInfo::format, _LogInfo::path, RelinquishWizardMemory(), _LogInfo::timer, and WizardFalse.

Referenced by LogComponentTerminus().

WizardExport const LogInfo* GetLogInfo | ( | const char * | name,
|  | ExceptionInfo * | exception |
| ) |  |  |

References GetNextValueInLinkedList(), GetValueFromLinkedList(), GetWizardModule, InitializeLogList(), InsertValueInLinkedList(), instantiate_log, IsLinkedListEmpty(), LocaleCompare(), LockSemaphoreInfo(), log_list, log_semaphore, _LogInfo::name, OptionWarning, RemoveElementByValueFromLinkedList(), ResetLinkedListIterator(), ThrowWizardException(), UnlockSemaphoreInfo(), and WizardFalse.

Referenced by CloseWizardLog(), GetLogInfoList(), GetLogList(), IsEventLogging(), LogWizardEventList(), SetLogEventMask(), SetLogFormat(), and TranslateEvent().

WizardExport const LogInfo** GetLogInfoList | ( | const char * | pattern,
|  | size_t * | number_preferences,
|  | ExceptionInfo * | exception |
| ) |  |  |

References AcquireQuantumMemory(), GetLogInfo(), GetNextValueInLinkedList(), GetNumberOfElementsInLinkedList(), GetWizardModule, GlobExpression(), LockSemaphoreInfo(), log_list, log_semaphore, LogInfoCompare(), LogWizardEvent(), _LogInfo::name, ResetLinkedListIterator(), _LogInfo::stealth, TraceEvent, UnlockSemaphoreInfo(), and WizardFalse.

Referenced by ListLogInfo().

WizardExport char** GetLogList | ( | const char * | pattern,
|  | size_t * | number_preferences,
|  | ExceptionInfo * | exception |
| ) |  |  |

References AcquireQuantumMemory(), ConstantString(), GetLogInfo(), GetNextValueInLinkedList(), GetNumberOfElementsInLinkedList(), GetWizardModule, GlobExpression(), LockSemaphoreInfo(), log_list, log_semaphore, LogCompare(), LogWizardEvent(), _LogInfo::name, ResetLinkedListIterator(), _LogInfo::stealth, TraceEvent, UnlockSemaphoreInfo(), and WizardFalse.

WizardExport const char* GetLogName | ( | void |  | ) |

References log_name.

Referenced by TranslateEvent(), and TranslateFilename().

static WizardBooleanType InitializeLogList | ( | ExceptionInfo * | exception | ) | `[static]`

References AcquireSemaphoreInfo(), instantiate_log, LoadLogLists(), LockSemaphoreInfo(), log_list, log_semaphore, LogFilename, UnlockSemaphoreInfo(), WizardFalse, and WizardTrue.

Referenced by GetLogInfo().

WizardExport WizardBooleanType IsEventLogging | ( | void |  | ) |

References AcquireExceptionInfo(), DestroyExceptionInfo(), _LogInfo::event_mask, GetLogInfo(), IsLinkedListEmpty(), log_list, NoEvents, WizardFalse, and WizardTrue.

Referenced by AddChildToXMLTree(), CloseWizardLog(), GetBlobInfo(), LogWizardEventList(), NewHashmap(), NewSplayTree(), NewXMLTreeTag(), and WizardsToolkitGenesis().

WizardExport WizardBooleanType ListLogInfo | ( | FILE * | file,
|  | ExceptionInfo * | exception |
| ) |  |  |

References FormatWizardSize(), _LogInfo::generations, GetLogInfoList(), LocaleCompare(), MegabytesToBytes, _LogInfo::path, RelinquishWizardMemory(), WizardFalse, and WizardTrue.

static WizardBooleanType LoadLogList | ( | const char * | xml,
|  | const char * | filename,
|  | const size_t | depth,
|  | ExceptionInfo * | exception |
| ) |  |  | `[static]`

References AcquireString(), AcquireTimerInfo(), AcquireWizardMemory(), AppendValueToLinkedList(), ConcatenateWizardString(), ConstantString(), CopyWizardString(), DestroyString(), DirectorySeparator, _LogInfo::event_mask, _LogInfo::exempt, _LogInfo::filename, FileToString(), _LogInfo::format, _LogInfo::generations, GetPathComponent(), GetWizardModule, GetWizardToken(), _LogInfo::handler_mask, HeadPath, _LogInfo::limit, LocaleCompare(), LocaleNCompare(), log_list, MaxTextExtent, NewLinkedList(), ParseLogHandlers(), ParseWizardOption(), _LogInfo::path, RelinquishWizardMemory(), ResetWizardMemory(), ResourceFatalError, _LogInfo::signature, StringToUnsignedLong(), ThrowFatalException, ThrowWizardException(), _LogInfo::timer, WizardFalse, WizardLogEventOptions, and WizardTrue.

Referenced by LoadLogLists().

static WizardBooleanType LoadLogLists | ( | const char * | filename,
|  | ExceptionInfo * | exception |
| ) |  |  |

References AcquireTimerInfo(), AcquireWizardMemory(), AppendValueToLinkedList(), ConstantString(), DestroyConfigureOptions(), _LogMapInfo::event_mask, _LogInfo::event_mask, _LogInfo::exempt, FileError, _LogMapInfo::filename, _LogInfo::filename, _LogMapInfo::format, _LogInfo::format, GetConfigureOptions(), GetNextValueInLinkedList(), GetStringInfoDatum(), GetStringInfoPath(), GetWizardModule, _LogMapInfo::handler_mask, _LogInfo::handler_mask, LoadLogList(), log_list, LogMap, _LogInfo::name, NewLinkedList(), _LogInfo::path, ResetWizardMemory(), _LogInfo::signature, ThrowFileException, ThrowWizardException(), _LogInfo::timer, WizardFalse, and WizardTrue.

Referenced by InitializeLogList().

static int LogCompare | ( | const void * | x,
|  | const void * | y |
| ) |  |  | `[static]`

References LocaleCompare().

Referenced by GetLogList().

WizardExport WizardBooleanType LogComponentGenesis | ( | void |  | ) |

References AcquireSemaphoreInfo(), log_semaphore, and WizardTrue.

Referenced by WizardsToolkitGenesis().

WizardExport void LogComponentTerminus | ( | void |  | ) |

References AcquireSemaphoreInfo(), DestroyLinkedList(), DestroyLogElement(), DestroySemaphoreInfo(), instantiate_log, LockSemaphoreInfo(), log_list, log_semaphore, and UnlockSemaphoreInfo().

Referenced by WizardsToolkitTerminus().

static int LogInfoCompare | ( | const void * | x,
|  | const void * | y |
| ) |  |  | `[static]`

References LocaleCompare().

Referenced by GetLogInfoList().

WizardBooleanType LogWizardEvent | ( | const LogEventType | type,
|  | const char * | module,
|  | const char * | function,
|  | const size_t | line,
|  | const char * | format,
|  |  | ... |
| ) |  |  |

References LogWizardEventList().

Referenced by AcquireFileInfo(), AcquireFileLock(), AcquireUniqueFileResource(), AcquireWizardResource(), AddPathToXMLTree(), AppendFileExtension(), AppendValueToLinkedList(), AttachBlob(), AuthenticateKey(), AuthenticateSecretKey(), Base64Decode(), Base64Encode(), ClearLinkedList(), CloneSplayTree(), CloneString(), CloneStringInfo(), CloseBlob(), CompareStringInfo(), ConcatenateStringInfo(), ConstructHMAC(), DecipherCBCMode(), DecipherCFBMode(), DecipherCipher(), DecipherCTRMode(), DecipherECBMode(), DecipherOFBMode(), DeleteNodeByValueFromSplayTree(), DeleteNodeFromSplayTree(), DestroyAESInfo(), DestroyAuthenticateInfo(), DestroyBlob(), DestroyBZIPInfo(), DestroyCipherInfo(), DestroyConfigureOptions(), DestroyCRC64Info(), DestroyEntropyInfo(), DestroyFileInfo(), DestroyHashInfo(), DestroyHashmap(), DestroyHMACInfo(), DestroyKeyInfo(), DestroyKeyringInfo(), DestroyLinkedList(), DestroyLZMAInfo(), DestroyMD5Info(), DestroyRandomInfo(), DestroySecretInfo(), DestroySerpentInfo(), DestroySHA1Info(), DestroySHA224Info(), DestroySHA256Info(), DestroySHA384Info(), DestroySHA512Info(), DestroyStringInfo(), DestroyTwofishInfo(), DestroyXMLTree(), DestroyZIPInfo(), DetachBlob(), EncipherCBCMode(), EncipherCFBMode(), EncipherCipher(), EncipherCTRMode(), EncipherECBMode(), EncipherOFBMode(), EOFBlob(), ExportKeyringKey(), FileToBlob(), FileToString(), FileToStringInfo(), FinalizeCRC64(), FinalizeHash(), FinalizeHMAC(), FinalizeMD5(), FinalizeSHA1(), FinalizeSHA224(), FinalizeSHA256(), FinalizeSHA384(), FinalizeSHA512(), GenerateAuthenticateKey(), GenerateCipherNonce(), GenerateSecretKey(), GenerateSessionKey(), GetAESBlocksize(), GetAuthenticateId(), GetAuthenticateKey(), GetAuthenticateKeyLength(), GetAuthenticatePassphrase(), GetBlobFilename(), GetBlobProperties(), GetBlobSize(), GetBZIPChaos(), GetCipherBlocksize(), GetCipherNonce(), GetConfigureInfoList(), GetConfigureList(), GetConfigureOptions(), GetConfigurePaths(), GetConfigureValue(), GetCRC64Blocksize(), GetCRC64CyclicRedundancyCheck(), GetCRC64Digest(), GetCRC64Digestsize(), GetEntropyChaos(), GetEntropyFromReservoir(), GetFileDescriptor(), GetFilePath(), GetFileProperties(), GetHashBlocksize(), GetHashDigest(), GetHashDigestsize(), GetHashHexDigest(), GetHMACDigest(), GetHMACDigestsize(), GetKeyInfo(), GetKeyringKey(), GetKeyringNonce(), GetLastValueInLinkedList(), GetLogInfoList(), GetLogList(), GetLZMAChaos(), GetMD5Blocksize(), GetMD5Digest(), GetMD5Digestsize(), GetMimeDescription(), GetMimeInfoList(), GetMimeList(), GetMimeType(), GetNextKeyInHashmap(), GetNextKeyInSplayTree(), GetNextValueInHashmap(), GetNextValueInLinkedList(), GetNextValueInSplayTree(), GetNextXMLTreeTag(), GetNumberOfElementsInLinkedList(), GetNumberOfEntriesInHashmap(), GetNumberOfNodesInSplayTree(), GetPathComponent(), GetSecretId(), GetSecretKey(), GetSecretKeyLength(), GetSecretPassphrase(), GetSerpentBlocksize(), GetSHA1Blocksize(), GetSHA1Digest(), GetSHA1Digestsize(), GetSHA224Blocksize(), GetSHA224Digest(), GetSHA224Digestsize(), GetSHA256Blocksize(), GetSHA256Digest(), GetSHA256Digestsize(), GetSHA384Blocksize(), GetSHA384Digest(), GetSHA384Digestsize(), GetSHA512Blocksize(), GetSHA512Digest(), GetSHA512Digestsize(), GetStringInfoCRC(), GetTwofishBlocksize(), GetValueFromHashmap(), GetValueFromLinkedList(), GetValueFromSplayTree(), GetXMLTreeAttribute(), GetXMLTreeAttributes(), GetXMLTreeChild(), GetXMLTreeContent(), GetXMLTreeOrdered(), GetXMLTreePath(), GetXMLTreeProcessingInstructions(), GetXMLTreeSibling(), GetXMLTreeTag(), GetZIPChaos(), HexStringToStringInfo(), ImportKeyringKey(), IncreaseBZIP(), IncreaseEntropy(), IncreaseLZMA(), IncreaseZIP(), InitializeCRC64(), InitializeHash(), InitializeHMAC(), InitializeMD5(), InitializeSHA1(), InitializeSHA224(), InitializeSHA256(), InitializeSHA384(), InitializeSHA512(), InsertValueInLinkedList(), InsertValueInSortedLinkedList(), IsHashmapEmpty(), IsLinkedListEmpty(), LinkedListToArray(), LoadConfigureList(), LoadMimeList(), OpenBlob(), PrintKeyringProperties(), PrintStringInfo(), PruneTagFromXMLTree(), PutEntryInHashmap(), ReadFileChunk(), RegisterWizardSignalHandler(), RelinquishUniqueFileResource(), RelinquishWizardResource(), RemoveElementByValueFromLinkedList(), RemoveElementFromLinkedList(), RemoveEntryFromHashmap(), RemoveLastElementFromLinkedList(), RemoveNodeByValueFromSplayTree(), RemoveNodeFromSplayTree(), ResetCipherNonce(), ResetHashmapIterator(), ResetHMAC(), ResetLinkedListIterator(), ResetSplayTree(), ResetSplayTreeIterator(), ResetStringInfo(), RestoreBZIP(), RestoreEntropy(), RestoreLZMA(), RestoreZIP(), SaveEntropyToReservoir(), SetAESKey(), SetAuthenticateId(), SetAuthenticateKeyLength(), SetAuthenticatePassphrase(), SetCipherKey(), SetCipherNonce(), SetKeyInfo(), SetSecretKeyLength(), SetSerpentKey(), SetStringInfo(), SetStringInfoDatum(), SetStringInfoLength(), SetStringInfoPath(), SetTwofishKey(), SetXMLTreeAttribute(), SetXMLTreeContent(), SplitStringInfo(), StringToStringInfo(), SyncBlob(), TellBlob(), ThrowWizardExceptionList(), UpdateCRC64(), UpdateHash(), UpdateHMAC(), WriteFile32Bits(), WriteFile64Bits(), WriteFileChunk(), and XMLTreeInfoToXML().

WizardBooleanType LogWizardEventList | ( | const LogEventType | type,
|  | const char * | module,
|  | const char * | function,
|  | const size_t | line,
|  | const char * | format,
|  | va_list | operands |
| ) |  |  |

References AcquireExceptionInfo(), _LogInfo::append, ConsoleHandler, ContinueTimer(), DebugHandler, DestroyExceptionInfo(), _LogInfo::event_mask, EventHandler, _LogInfo::file, FileHandler, fileno, _LogInfo::generation, GetLogInfo(), _LogInfo::handler_mask, IsAccessible(), IsEventLogging(), _LogInfo::limit, LockSemaphoreInfo(), log_semaphore, MaxTextExtent, NTReportEvent(), RelinquishWizardMemory(), StderrHandler, StdoutHandler, _LogInfo::timer, TranslateEvent(), TranslateFilename(), UnlockSemaphoreInfo(), vsnprintf, WizardFalse, WizardLogEventOptions, WizardOpenStream(), WizardOptionToMnemonic(), and WizardTrue.

Referenced by LogWizardEvent().

static LogHandlerType ParseLogHandlers | ( | const char * | handlers | ) | `[static]`

References LocaleNCompare(), LogHandlers, _HandlerInfo::name, and UndefinedHandler.

Referenced by LoadLogList().

WizardExport LogEventType SetLogEventMask | ( | const char * | events | ) |

References AcquireExceptionInfo(), DestroyExceptionInfo(), _LogInfo::event_mask, GetLogInfo(), GetValueFromLinkedList(), LockSemaphoreInfo(), log_list, log_semaphore, ParseWizardOption(), UnlockSemaphoreInfo(), WizardLogEventOptions, and WizardTrue.

Referenced by WizardsToolkitGenesis().

WizardExport void SetLogFormat | ( | const char * | format | ) |

References AcquireExceptionInfo(), ConstantString(), DestroyExceptionInfo(), DestroyString(), _LogInfo::format, GetLogInfo(), LockSemaphoreInfo(), log_semaphore, and UnlockSemaphoreInfo().

WizardExport const char* SetLogName | ( | const char * | name | ) |

References CopyWizardString(), log_name, and MaxTextExtent.

static char* TranslateEvent | ( | const LogEventType | wizard_unusedtype,
|  | const char * | module,
|  | const char * | function,
|  | const size_t | line,
|  | const char * | domain,
|  | const char * | event |
| ) |  |  | `[static]`

References AcquireExceptionInfo(), AcquireString(), CopyWizardString(), DestroyExceptionInfo(), DirectorySeparator, _LogInfo::format, FormatWizardString(), FormatWizardTime(), _LogInfo::generation, _LogInfo::generations, GetClientName(), GetElapsedTime(), GetLogInfo(), GetLogName(), getpid, GetUserTime(), GetWizardThreadSignature(), LocaleCompare(), MaxTextExtent, ResizeQuantumMemory(), _LogInfo::timer, and WizardLibVersionText.

Referenced by LogWizardEventList().

static char* TranslateFilename | ( | const LogInfo * | log_info | ) | `[static]`

References AcquireString(), CopyWizardString(), _LogInfo::filename, FormatWizardString(), _LogInfo::generation, _LogInfo::generations, GetClientName(), GetLogName(), getpid, MaxTextExtent, ResizeQuantumMemory(), and WizardLibVersionText.

Referenced by LogWizardEventList().

## Variable Documentation

volatile WizardBooleanType instantiate_log = WizardFalse`[static]`

Referenced by GetLogInfo(), InitializeLogList(), and LogComponentTerminus().

LinkedListInfo* log_list = (LinkedListInfo *) NULL`[static]`

Referenced by GetLogInfo(), GetLogInfoList(), GetLogList(), InitializeLogList(), IsEventLogging(), LoadLogList(), LoadLogLists(), LogComponentTerminus(), and SetLogEventMask().

char log_name[MaxTextExtent] = "Wizard"`[static]`

Referenced by GetLogName(), and SetLogName().

SemaphoreInfo* log_semaphore = (SemaphoreInfo *) NULL`[static]`

Referenced by CloseWizardLog(), GetLogInfo(), GetLogInfoList(), GetLogList(), InitializeLogList(), LogComponentGenesis(), LogComponentTerminus(), LogWizardEventList(), SetLogEventMask(), and SetLogFormat().

const HandlerInfo LogHandlers[]`[static]`

Initial value:

      {
        { "console", ConsoleHandler },
        { "debug", DebugHandler },
        { "event", EventHandler },
        { "file", FileHandler },
        { "none", NoHandler },
        { "stderr", StderrHandler },
        { "stdout", StdoutHandler },
        { (char *) NULL, UndefinedHandler }
      }

Referenced by ParseLogHandlers().

const LogMapInfo LogMap[]`[static]`

Initial value:

      {
        { NoEvents, ConsoleHandler, "Magick-%d.log",
          "%t %r %u %v %d %c[%p]: %m/%f/%l/%d\n  %e" }
      }

Referenced by LoadLogLists().