cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % L OOO GGGG % |
| 7 | % L O O G % |
| 8 | % L O O G GG % |
| 9 | % L O O G G % |
| 10 | % LLLLL OOO GGG % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickCore Log Events % |
| 14 | % % |
| 15 | % Software Design % |
cristy | de984cd | 2013-12-01 14:49:27 +0000 | [diff] [blame^] | 16 | % Cristy % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 17 | % September 2002 % |
| 18 | % % |
| 19 | % % |
cristy | fe676ee | 2013-11-18 13:03:38 +0000 | [diff] [blame] | 20 | % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % |
| 37 | */ |
| 38 | |
| 39 | /* |
| 40 | Include declarations. |
| 41 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 42 | #include "MagickCore/studio.h" |
| 43 | #include "MagickCore/blob.h" |
| 44 | #include "MagickCore/client.h" |
| 45 | #include "MagickCore/configure.h" |
cristy | 9639ba3 | 2011-09-05 15:09:42 +0000 | [diff] [blame] | 46 | #include "MagickCore/configure-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 47 | #include "MagickCore/exception.h" |
| 48 | #include "MagickCore/exception-private.h" |
| 49 | #include "MagickCore/hashmap.h" |
| 50 | #include "MagickCore/log.h" |
cristy | 5ff4eaf | 2011-09-03 01:38:02 +0000 | [diff] [blame] | 51 | #include "MagickCore/log-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 52 | #include "MagickCore/memory_.h" |
| 53 | #include "MagickCore/option.h" |
| 54 | #include "MagickCore/semaphore.h" |
| 55 | #include "MagickCore/timer.h" |
| 56 | #include "MagickCore/string_.h" |
| 57 | #include "MagickCore/string-private.h" |
| 58 | #include "MagickCore/token.h" |
| 59 | #include "MagickCore/thread_.h" |
| 60 | #include "MagickCore/thread-private.h" |
| 61 | #include "MagickCore/utility.h" |
cristy | d1dd6e4 | 2011-09-04 01:46:08 +0000 | [diff] [blame] | 62 | #include "MagickCore/utility-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 63 | #include "MagickCore/version.h" |
| 64 | #include "MagickCore/xml-tree.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 65 | |
| 66 | /* |
| 67 | Define declarations. |
| 68 | */ |
| 69 | #define LogFilename "log.xml" |
| 70 | |
| 71 | /* |
| 72 | Typedef declarations. |
| 73 | */ |
| 74 | typedef enum |
| 75 | { |
| 76 | UndefinedHandler = 0x0000, |
| 77 | NoHandler = 0x0000, |
| 78 | ConsoleHandler = 0x0001, |
| 79 | StdoutHandler = 0x0002, |
| 80 | StderrHandler = 0x0004, |
| 81 | FileHandler = 0x0008, |
| 82 | DebugHandler = 0x0010, |
| 83 | EventHandler = 0x0020 |
| 84 | } LogHandlerType; |
| 85 | |
| 86 | typedef struct _EventInfo |
| 87 | { |
| 88 | char |
| 89 | *name; |
| 90 | |
| 91 | LogEventType |
| 92 | event; |
| 93 | } EventInfo; |
| 94 | |
| 95 | typedef struct _HandlerInfo |
| 96 | { |
| 97 | const char |
| 98 | *name; |
| 99 | |
| 100 | LogHandlerType |
| 101 | handler; |
| 102 | } HandlerInfo; |
| 103 | |
| 104 | struct _LogInfo |
| 105 | { |
| 106 | LogEventType |
| 107 | event_mask; |
| 108 | |
| 109 | LogHandlerType |
| 110 | handler_mask; |
| 111 | |
| 112 | char |
| 113 | *path, |
| 114 | *name, |
| 115 | *filename, |
| 116 | *format; |
| 117 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 118 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 119 | generations, |
| 120 | limit; |
| 121 | |
| 122 | FILE |
| 123 | *file; |
| 124 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 125 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 126 | generation; |
| 127 | |
| 128 | MagickBooleanType |
| 129 | append, |
| 130 | stealth; |
| 131 | |
| 132 | TimerInfo |
| 133 | timer; |
| 134 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 135 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 136 | signature; |
| 137 | }; |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 138 | |
| 139 | typedef struct _LogMapInfo |
| 140 | { |
| 141 | const LogEventType |
| 142 | event_mask; |
| 143 | |
| 144 | const LogHandlerType |
| 145 | handler_mask; |
| 146 | |
| 147 | const char |
| 148 | *filename, |
| 149 | *format; |
| 150 | } LogMapInfo; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 151 | |
| 152 | /* |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 153 | Static declarations. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 154 | */ |
| 155 | static const HandlerInfo |
| 156 | LogHandlers[] = |
| 157 | { |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 158 | { "Console", ConsoleHandler }, |
| 159 | { "Debug", DebugHandler }, |
| 160 | { "Event", EventHandler }, |
| 161 | { "File", FileHandler }, |
| 162 | { "None", NoHandler }, |
| 163 | { "Stderr", StderrHandler }, |
| 164 | { "Stdout", StdoutHandler }, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 165 | { (char *) NULL, UndefinedHandler } |
| 166 | }; |
| 167 | |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 168 | static const LogMapInfo |
| 169 | LogMap[] = |
| 170 | { |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 171 | { NoEvents, ConsoleHandler, "Magick-%g.log", |
| 172 | "%t %r %u %v %d %c[%p]: %m/%f/%l/%d\\n %e" } |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 173 | }; |
| 174 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 175 | static char |
| 176 | log_name[MaxTextExtent] = "Magick"; |
| 177 | |
| 178 | static LinkedListInfo |
| 179 | *log_list = (LinkedListInfo *) NULL; |
| 180 | |
| 181 | static SemaphoreInfo |
| 182 | *log_semaphore = (SemaphoreInfo *) NULL; |
| 183 | |
| 184 | static volatile MagickBooleanType |
| 185 | instantiate_log = MagickFalse; |
| 186 | |
| 187 | /* |
| 188 | Forward declarations. |
| 189 | */ |
| 190 | static LogHandlerType |
| 191 | ParseLogHandlers(const char *); |
| 192 | |
| 193 | static LogInfo |
| 194 | *GetLogInfo(const char *,ExceptionInfo *); |
| 195 | |
| 196 | static MagickBooleanType |
| 197 | InitializeLogList(ExceptionInfo *), |
| 198 | LoadLogLists(const char *,ExceptionInfo *); |
| 199 | |
| 200 | /* |
| 201 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 202 | % % |
| 203 | % % |
| 204 | % % |
| 205 | % C l o s e M a g i c k L o g % |
| 206 | % % |
| 207 | % % |
| 208 | % % |
| 209 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 210 | % |
| 211 | % CloseMagickLog() closes the Magick log. |
| 212 | % |
| 213 | % The format of the CloseMagickLog method is: |
| 214 | % |
| 215 | % CloseMagickLog(void) |
| 216 | % |
| 217 | */ |
| 218 | MagickExport void CloseMagickLog(void) |
| 219 | { |
| 220 | ExceptionInfo |
| 221 | *exception; |
| 222 | |
| 223 | LogInfo |
| 224 | *log_info; |
| 225 | |
| 226 | if (IsEventLogging() == MagickFalse) |
| 227 | return; |
| 228 | exception=AcquireExceptionInfo(); |
| 229 | log_info=GetLogInfo("*",exception); |
| 230 | exception=DestroyExceptionInfo(exception); |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 231 | LockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 232 | if (log_info->file != (FILE *) NULL) |
| 233 | { |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 234 | (void) FormatLocaleFile(log_info->file,"</log>\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 235 | (void) fclose(log_info->file); |
| 236 | log_info->file=(FILE *) NULL; |
| 237 | } |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 238 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /* |
| 242 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 243 | % % |
| 244 | % % |
| 245 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 246 | + G e t L o g I n f o % |
| 247 | % % |
| 248 | % % |
| 249 | % % |
| 250 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 251 | % |
| 252 | % GetLogInfo() searches the log list for the specified name and if found |
| 253 | % returns attributes for that log. |
| 254 | % |
| 255 | % The format of the GetLogInfo method is: |
| 256 | % |
| 257 | % LogInfo *GetLogInfo(const char *name,ExceptionInfo *exception) |
| 258 | % |
| 259 | % A description of each parameter follows: |
| 260 | % |
| 261 | % o name: the log name. |
| 262 | % |
| 263 | % o exception: return any errors or warnings in this structure. |
| 264 | % |
| 265 | */ |
| 266 | static LogInfo *GetLogInfo(const char *name,ExceptionInfo *exception) |
| 267 | { |
| 268 | register LogInfo |
| 269 | *p; |
| 270 | |
| 271 | assert(exception != (ExceptionInfo *) NULL); |
| 272 | if ((log_list == (LinkedListInfo *) NULL) || (instantiate_log == MagickFalse)) |
| 273 | if (InitializeLogList(exception) == MagickFalse) |
| 274 | return((LogInfo *) NULL); |
| 275 | if ((log_list == (LinkedListInfo *) NULL) || |
| 276 | (IsLinkedListEmpty(log_list) != MagickFalse)) |
| 277 | return((LogInfo *) NULL); |
| 278 | if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0)) |
| 279 | return((LogInfo *) GetValueFromLinkedList(log_list,0)); |
| 280 | /* |
| 281 | Search for log tag. |
| 282 | */ |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 283 | LockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 284 | ResetLinkedListIterator(log_list); |
| 285 | p=(LogInfo *) GetNextValueInLinkedList(log_list); |
| 286 | while (p != (LogInfo *) NULL) |
| 287 | { |
| 288 | if (LocaleCompare(name,p->name) == 0) |
| 289 | break; |
| 290 | p=(LogInfo *) GetNextValueInLinkedList(log_list); |
| 291 | } |
| 292 | if (p != (LogInfo *) NULL) |
| 293 | (void) InsertValueInLinkedList(log_list,0, |
| 294 | RemoveElementByValueFromLinkedList(log_list,p)); |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 295 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 296 | return(p); |
| 297 | } |
| 298 | |
| 299 | /* |
| 300 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 301 | % % |
| 302 | % % |
| 303 | % % |
| 304 | % G e t L o g I n f o L i s t % |
| 305 | % % |
| 306 | % % |
| 307 | % % |
| 308 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 309 | % |
| 310 | % GetLogInfoList() returns any logs that match the specified pattern. |
| 311 | % |
| 312 | % The format of the GetLogInfoList function is: |
| 313 | % |
| 314 | % const LogInfo **GetLogInfoList(const char *pattern, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 315 | % size_t *number_preferences,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 316 | % |
| 317 | % A description of each parameter follows: |
| 318 | % |
| 319 | % o pattern: Specifies a pointer to a text string containing a pattern. |
| 320 | % |
| 321 | % o number_preferences: This integer returns the number of logs in the list. |
| 322 | % |
| 323 | % o exception: return any errors or warnings in this structure. |
| 324 | % |
| 325 | */ |
| 326 | #if defined(__cplusplus) || defined(c_plusplus) |
| 327 | extern "C" { |
| 328 | #endif |
| 329 | |
| 330 | static int LogInfoCompare(const void *x,const void *y) |
| 331 | { |
| 332 | const LogInfo |
| 333 | **p, |
| 334 | **q; |
| 335 | |
| 336 | p=(const LogInfo **) x, |
| 337 | q=(const LogInfo **) y; |
| 338 | if (LocaleCompare((*p)->path,(*q)->path) == 0) |
| 339 | return(LocaleCompare((*p)->name,(*q)->name)); |
| 340 | return(LocaleCompare((*p)->path,(*q)->path)); |
| 341 | } |
| 342 | |
| 343 | #if defined(__cplusplus) || defined(c_plusplus) |
| 344 | } |
| 345 | #endif |
| 346 | |
| 347 | MagickExport const LogInfo **GetLogInfoList(const char *pattern, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 348 | size_t *number_preferences,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 349 | { |
| 350 | const LogInfo |
| 351 | **preferences; |
| 352 | |
| 353 | register const LogInfo |
| 354 | *p; |
| 355 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 356 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 357 | i; |
| 358 | |
| 359 | /* |
| 360 | Allocate log list. |
| 361 | */ |
| 362 | assert(pattern != (char *) NULL); |
| 363 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 364 | assert(number_preferences != (size_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 365 | *number_preferences=0; |
| 366 | p=GetLogInfo("*",exception); |
| 367 | if (p == (const LogInfo *) NULL) |
| 368 | return((const LogInfo **) NULL); |
| 369 | preferences=(const LogInfo **) AcquireQuantumMemory((size_t) |
| 370 | GetNumberOfElementsInLinkedList(log_list)+1UL,sizeof(*preferences)); |
| 371 | if (preferences == (const LogInfo **) NULL) |
| 372 | return((const LogInfo **) NULL); |
| 373 | /* |
| 374 | Generate log list. |
| 375 | */ |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 376 | LockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 377 | ResetLinkedListIterator(log_list); |
| 378 | p=(const LogInfo *) GetNextValueInLinkedList(log_list); |
| 379 | for (i=0; p != (const LogInfo *) NULL; ) |
| 380 | { |
| 381 | if ((p->stealth == MagickFalse) && |
| 382 | (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse)) |
| 383 | preferences[i++]=p; |
| 384 | p=(const LogInfo *) GetNextValueInLinkedList(log_list); |
| 385 | } |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 386 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 387 | qsort((void *) preferences,(size_t) i,sizeof(*preferences),LogInfoCompare); |
| 388 | preferences[i]=(LogInfo *) NULL; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 389 | *number_preferences=(size_t) i; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 390 | return(preferences); |
| 391 | } |
| 392 | |
| 393 | /* |
| 394 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 395 | % % |
| 396 | % % |
| 397 | % % |
| 398 | % G e t L o g L i s t % |
| 399 | % % |
| 400 | % % |
| 401 | % % |
| 402 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 403 | % |
| 404 | % GetLogList() returns any logs that match the specified pattern. |
| 405 | % |
| 406 | % The format of the GetLogList function is: |
| 407 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 408 | % char **GetLogList(const char *pattern,size_t *number_preferences, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 409 | % ExceptionInfo *exception) |
| 410 | % |
| 411 | % A description of each parameter follows: |
| 412 | % |
| 413 | % o pattern: Specifies a pointer to a text string containing a pattern. |
| 414 | % |
| 415 | % o number_preferences: This integer returns the number of logs in the list. |
| 416 | % |
| 417 | % o exception: return any errors or warnings in this structure. |
| 418 | % |
| 419 | */ |
| 420 | |
| 421 | #if defined(__cplusplus) || defined(c_plusplus) |
| 422 | extern "C" { |
| 423 | #endif |
| 424 | |
| 425 | static int LogCompare(const void *x,const void *y) |
| 426 | { |
| 427 | register const char |
| 428 | **p, |
| 429 | **q; |
| 430 | |
| 431 | p=(const char **) x; |
| 432 | q=(const char **) y; |
| 433 | return(LocaleCompare(*p,*q)); |
| 434 | } |
| 435 | |
| 436 | #if defined(__cplusplus) || defined(c_plusplus) |
| 437 | } |
| 438 | #endif |
| 439 | |
| 440 | MagickExport char **GetLogList(const char *pattern, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 441 | size_t *number_preferences,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 442 | { |
| 443 | char |
| 444 | **preferences; |
| 445 | |
| 446 | register const LogInfo |
| 447 | *p; |
| 448 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 449 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 450 | i; |
| 451 | |
| 452 | /* |
| 453 | Allocate log list. |
| 454 | */ |
| 455 | assert(pattern != (char *) NULL); |
| 456 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 457 | assert(number_preferences != (size_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 458 | *number_preferences=0; |
| 459 | p=GetLogInfo("*",exception); |
| 460 | if (p == (const LogInfo *) NULL) |
| 461 | return((char **) NULL); |
| 462 | preferences=(char **) AcquireQuantumMemory((size_t) |
| 463 | GetNumberOfElementsInLinkedList(log_list)+1UL,sizeof(*preferences)); |
| 464 | if (preferences == (char **) NULL) |
| 465 | return((char **) NULL); |
| 466 | /* |
| 467 | Generate log list. |
| 468 | */ |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 469 | LockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 470 | ResetLinkedListIterator(log_list); |
| 471 | p=(const LogInfo *) GetNextValueInLinkedList(log_list); |
| 472 | for (i=0; p != (const LogInfo *) NULL; ) |
| 473 | { |
| 474 | if ((p->stealth == MagickFalse) && |
| 475 | (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse)) |
| 476 | preferences[i++]=ConstantString(p->name); |
| 477 | p=(const LogInfo *) GetNextValueInLinkedList(log_list); |
| 478 | } |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 479 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 480 | qsort((void *) preferences,(size_t) i,sizeof(*preferences),LogCompare); |
| 481 | preferences[i]=(char *) NULL; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 482 | *number_preferences=(size_t) i; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 483 | return(preferences); |
| 484 | } |
| 485 | |
| 486 | /* |
| 487 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 488 | % % |
| 489 | % % |
| 490 | % % |
| 491 | % G e t L o g N a m e % |
| 492 | % % |
| 493 | % % |
| 494 | % % |
| 495 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 496 | % |
| 497 | % GetLogName() returns the current log name. |
| 498 | % |
| 499 | % The format of the GetLogName method is: |
| 500 | % |
| 501 | % const char *GetLogName(void) |
| 502 | % |
| 503 | */ |
| 504 | MagickExport const char *GetLogName(void) |
| 505 | { |
| 506 | return(log_name); |
| 507 | } |
| 508 | |
| 509 | /* |
| 510 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 511 | % % |
| 512 | % % |
| 513 | % % |
| 514 | + I n i t i a l i z e L o g L i s t % |
| 515 | % % |
| 516 | % % |
| 517 | % % |
| 518 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 519 | % |
| 520 | % InitializeLogList() initialize the log list. |
| 521 | % |
| 522 | % The format of the InitializeLogList method is: |
| 523 | % |
| 524 | % MagickBooleanType InitializeLogList(ExceptionInfo *exception) |
| 525 | % |
| 526 | % A description of each parameter follows. |
| 527 | % |
| 528 | % o exception: return any errors or warnings in this structure. |
| 529 | % |
| 530 | */ |
| 531 | static MagickBooleanType InitializeLogList(ExceptionInfo *exception) |
| 532 | { |
| 533 | if ((log_list == (LinkedListInfo *) NULL) && (instantiate_log == MagickFalse)) |
| 534 | { |
cristy | 4e1dff6 | 2009-10-25 20:36:03 +0000 | [diff] [blame] | 535 | if (log_semaphore == (SemaphoreInfo *) NULL) |
| 536 | AcquireSemaphoreInfo(&log_semaphore); |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 537 | LockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 538 | if ((log_list == (LinkedListInfo *) NULL) && |
| 539 | (instantiate_log == MagickFalse)) |
| 540 | { |
| 541 | (void) LoadLogLists(LogFilename,exception); |
| 542 | instantiate_log=MagickTrue; |
| 543 | } |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 544 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 545 | } |
| 546 | return(log_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse); |
| 547 | } |
| 548 | |
| 549 | /* |
| 550 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 551 | % % |
| 552 | % % |
| 553 | % % |
| 554 | % I s E v e n t L o g g i n g % |
| 555 | % % |
| 556 | % % |
| 557 | % % |
| 558 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 559 | % |
| 560 | % IsEventLogging() returns MagickTrue if debug of events is enabled otherwise |
| 561 | % MagickFalse. |
| 562 | % |
| 563 | % The format of the IsEventLogging method is: |
| 564 | % |
| 565 | % MagickBooleanType IsEventLogging(void) |
| 566 | % |
| 567 | */ |
| 568 | MagickExport MagickBooleanType IsEventLogging(void) |
| 569 | { |
| 570 | const LogInfo |
| 571 | *log_info; |
| 572 | |
| 573 | ExceptionInfo |
| 574 | *exception; |
| 575 | |
| 576 | if ((log_list == (LinkedListInfo *) NULL) || |
| 577 | (IsLinkedListEmpty(log_list) != MagickFalse)) |
| 578 | return(MagickFalse); |
| 579 | exception=AcquireExceptionInfo(); |
| 580 | log_info=GetLogInfo("*",exception); |
| 581 | exception=DestroyExceptionInfo(exception); |
| 582 | return(log_info->event_mask != NoEvents ? MagickTrue : MagickFalse); |
| 583 | } |
| 584 | /* |
| 585 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 586 | % % |
| 587 | % % |
| 588 | % % |
| 589 | % L i s t L o g I n f o % |
| 590 | % % |
| 591 | % % |
| 592 | % % |
| 593 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 594 | % |
| 595 | % ListLogInfo() lists the log info to a file. |
| 596 | % |
| 597 | % The format of the ListLogInfo method is: |
| 598 | % |
| 599 | % MagickBooleanType ListLogInfo(FILE *file,ExceptionInfo *exception) |
| 600 | % |
| 601 | % A description of each parameter follows. |
| 602 | % |
| 603 | % o file: An pointer to a FILE. |
| 604 | % |
| 605 | % o exception: return any errors or warnings in this structure. |
| 606 | % |
| 607 | */ |
| 608 | MagickExport MagickBooleanType ListLogInfo(FILE *file,ExceptionInfo *exception) |
| 609 | { |
| 610 | #define MegabytesToBytes(value) ((MagickSizeType) (value)*1024*1024) |
| 611 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 612 | const char |
| 613 | *path; |
| 614 | |
| 615 | const LogInfo |
| 616 | **log_info; |
| 617 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 618 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 619 | i; |
| 620 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 621 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 622 | number_aliases; |
| 623 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 624 | ssize_t |
| 625 | j; |
| 626 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 627 | if (file == (const FILE *) NULL) |
| 628 | file=stdout; |
| 629 | log_info=GetLogInfoList("*",&number_aliases,exception); |
| 630 | if (log_info == (const LogInfo **) NULL) |
| 631 | return(MagickFalse); |
| 632 | j=0; |
| 633 | path=(const char *) NULL; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 634 | for (i=0; i < (ssize_t) number_aliases; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 635 | { |
| 636 | if (log_info[i]->stealth != MagickFalse) |
| 637 | continue; |
| 638 | if ((path == (const char *) NULL) || |
| 639 | (LocaleCompare(path,log_info[i]->path) != 0)) |
| 640 | { |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 641 | size_t |
| 642 | length; |
| 643 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 644 | if (log_info[i]->path != (char *) NULL) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 645 | (void) FormatLocaleFile(file,"\nPath: %s\n\n",log_info[i]->path); |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 646 | length=0; |
| 647 | for (j=0; j < (ssize_t) (8*sizeof(LogHandlerType)); j++) |
| 648 | { |
| 649 | size_t |
| 650 | mask; |
| 651 | |
cristy | fb8f6e1 | 2013-07-10 12:35:27 +0000 | [diff] [blame] | 652 | mask=1; |
| 653 | mask<<=j; |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 654 | if ((log_info[i]->handler_mask & mask) != 0) |
| 655 | { |
| 656 | (void) FormatLocaleFile(file,"%s ",LogHandlers[j].name); |
| 657 | length+=strlen(LogHandlers[j].name); |
| 658 | } |
| 659 | } |
| 660 | for (j=(ssize_t) length; j <= 12; j++) |
| 661 | (void) FormatLocaleFile(file," "); |
| 662 | (void) FormatLocaleFile(file," Generations Limit Format\n"); |
| 663 | (void) FormatLocaleFile(file,"-----------------------------------------" |
| 664 | "--------------------------------------\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 665 | } |
| 666 | path=log_info[i]->path; |
| 667 | if (log_info[i]->filename != (char *) NULL) |
| 668 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 669 | (void) FormatLocaleFile(file,"%s",log_info[i]->filename); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 670 | for (j=(ssize_t) strlen(log_info[i]->filename); j <= 16; j++) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 671 | (void) FormatLocaleFile(file," "); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 672 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 673 | (void) FormatLocaleFile(file,"%9g ",(double) log_info[i]->generations); |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 674 | (void) FormatLocaleFile(file,"%8g ",(double) log_info[i]->limit); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 675 | if (log_info[i]->format != (char *) NULL) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 676 | (void) FormatLocaleFile(file,"%s",log_info[i]->format); |
| 677 | (void) FormatLocaleFile(file,"\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 678 | } |
| 679 | (void) fflush(file); |
| 680 | log_info=(const LogInfo **) RelinquishMagickMemory((void *) log_info); |
| 681 | return(MagickTrue); |
| 682 | } |
| 683 | |
| 684 | /* |
| 685 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 686 | % % |
| 687 | % % |
| 688 | % % |
cristy | f34a145 | 2009-10-24 22:29:27 +0000 | [diff] [blame] | 689 | + L o g C o m p o n e n t G e n e s i s % |
| 690 | % % |
| 691 | % % |
| 692 | % % |
| 693 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 694 | % |
| 695 | % LogComponentGenesis() instantiates the log component. |
| 696 | % |
| 697 | % The format of the LogComponentGenesis method is: |
| 698 | % |
| 699 | % MagickBooleanType LogComponentGenesis(void) |
| 700 | % |
| 701 | */ |
cristy | 5ff4eaf | 2011-09-03 01:38:02 +0000 | [diff] [blame] | 702 | MagickPrivate MagickBooleanType LogComponentGenesis(void) |
cristy | f34a145 | 2009-10-24 22:29:27 +0000 | [diff] [blame] | 703 | { |
cristy | 85dfbbb | 2013-08-02 16:02:35 +0000 | [diff] [blame] | 704 | ExceptionInfo |
| 705 | *exception; |
| 706 | |
cristy | 165b609 | 2009-10-26 13:52:10 +0000 | [diff] [blame] | 707 | AcquireSemaphoreInfo(&log_semaphore); |
cristy | 85dfbbb | 2013-08-02 16:02:35 +0000 | [diff] [blame] | 708 | exception=AcquireExceptionInfo(); |
| 709 | (void) GetLogInfo("*",exception); |
| 710 | exception=DestroyExceptionInfo(exception); |
cristy | f34a145 | 2009-10-24 22:29:27 +0000 | [diff] [blame] | 711 | return(MagickTrue); |
| 712 | } |
| 713 | |
| 714 | /* |
| 715 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 716 | % % |
| 717 | % % |
| 718 | % % |
| 719 | + L o g C o m p o n e n t T e r m i n u s % |
| 720 | % % |
| 721 | % % |
| 722 | % % |
| 723 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 724 | % |
| 725 | % LogComponentTerminus() destroys the logging component. |
| 726 | % |
| 727 | % The format of the LogComponentTerminus method is: |
| 728 | % |
| 729 | % LogComponentTerminus(void) |
| 730 | % |
| 731 | */ |
| 732 | |
| 733 | static void *DestroyLogElement(void *log_info) |
| 734 | { |
| 735 | register LogInfo |
| 736 | *p; |
| 737 | |
| 738 | p=(LogInfo *) log_info; |
| 739 | if (p->file != (FILE *) NULL) |
| 740 | { |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 741 | (void) FormatLocaleFile(p->file,"</log>\n"); |
cristy | f34a145 | 2009-10-24 22:29:27 +0000 | [diff] [blame] | 742 | (void) fclose(p->file); |
| 743 | p->file=(FILE *) NULL; |
| 744 | } |
cristy | 5965b49 | 2013-08-17 14:04:22 +0000 | [diff] [blame] | 745 | if (p->format != (char *) NULL) |
| 746 | p->format=DestroyString(p->format); |
| 747 | if (p->path != (char *) NULL) |
| 748 | p->path=DestroyString(p->path); |
| 749 | if (p->filename != (char *) NULL) |
| 750 | p->filename=DestroyString(p->filename); |
cristy | f34a145 | 2009-10-24 22:29:27 +0000 | [diff] [blame] | 751 | p=(LogInfo *) RelinquishMagickMemory(p); |
| 752 | return((void *) NULL); |
| 753 | } |
| 754 | |
cristy | 5ff4eaf | 2011-09-03 01:38:02 +0000 | [diff] [blame] | 755 | MagickPrivate void LogComponentTerminus(void) |
cristy | f34a145 | 2009-10-24 22:29:27 +0000 | [diff] [blame] | 756 | { |
cristy | 18b1744 | 2009-10-25 18:36:48 +0000 | [diff] [blame] | 757 | if (log_semaphore == (SemaphoreInfo *) NULL) |
| 758 | AcquireSemaphoreInfo(&log_semaphore); |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 759 | LockSemaphoreInfo(log_semaphore); |
cristy | f34a145 | 2009-10-24 22:29:27 +0000 | [diff] [blame] | 760 | if (log_list != (LinkedListInfo *) NULL) |
| 761 | log_list=DestroyLinkedList(log_list,DestroyLogElement); |
| 762 | instantiate_log=MagickFalse; |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 763 | UnlockSemaphoreInfo(log_semaphore); |
cristy | f34a145 | 2009-10-24 22:29:27 +0000 | [diff] [blame] | 764 | DestroySemaphoreInfo(&log_semaphore); |
| 765 | } |
| 766 | |
| 767 | /* |
| 768 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 769 | % % |
| 770 | % % |
| 771 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 772 | % L o g M a g i c k E v e n t % |
| 773 | % % |
| 774 | % % |
| 775 | % % |
| 776 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 777 | % |
| 778 | % LogMagickEvent() logs an event as determined by the log configuration file. |
| 779 | % If an error occurs, MagickFalse is returned otherwise MagickTrue. |
| 780 | % |
| 781 | % The format of the LogMagickEvent method is: |
| 782 | % |
| 783 | % MagickBooleanType LogMagickEvent(const LogEventType type, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 784 | % const char *module,const char *function,const size_t line, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 785 | % const char *format,...) |
| 786 | % |
| 787 | % A description of each parameter follows: |
| 788 | % |
| 789 | % o type: the event type. |
| 790 | % |
| 791 | % o filename: the source module filename. |
| 792 | % |
| 793 | % o function: the function name. |
| 794 | % |
| 795 | % o line: the line number of the source module. |
| 796 | % |
| 797 | % o format: the output format. |
| 798 | % |
| 799 | */ |
| 800 | static char *TranslateEvent(const LogEventType magick_unused(type), |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 801 | const char *module,const char *function,const size_t line, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 802 | const char *domain,const char *event) |
| 803 | { |
| 804 | char |
| 805 | *text; |
| 806 | |
| 807 | double |
| 808 | elapsed_time, |
| 809 | user_time; |
| 810 | |
| 811 | ExceptionInfo |
| 812 | *exception; |
| 813 | |
| 814 | LogInfo |
| 815 | *log_info; |
| 816 | |
| 817 | register char |
| 818 | *q; |
| 819 | |
| 820 | register const char |
| 821 | *p; |
| 822 | |
| 823 | size_t |
| 824 | extent; |
| 825 | |
| 826 | time_t |
| 827 | seconds; |
| 828 | |
| 829 | exception=AcquireExceptionInfo(); |
| 830 | log_info=(LogInfo *) GetLogInfo("*",exception); |
| 831 | exception=DestroyExceptionInfo(exception); |
| 832 | seconds=time((time_t *) NULL); |
| 833 | elapsed_time=GetElapsedTime(&log_info->timer); |
| 834 | user_time=GetUserTime(&log_info->timer); |
| 835 | text=AcquireString(event); |
| 836 | if (log_info->format == (char *) NULL) |
| 837 | return(text); |
| 838 | extent=strlen(event)+MaxTextExtent; |
| 839 | if (LocaleCompare(log_info->format,"xml") == 0) |
| 840 | { |
| 841 | char |
| 842 | timestamp[MaxTextExtent]; |
| 843 | |
| 844 | /* |
| 845 | Translate event in "XML" format. |
| 846 | */ |
| 847 | (void) FormatMagickTime(seconds,extent,timestamp); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 848 | (void) FormatLocaleString(text,extent, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 849 | "<entry>\n" |
| 850 | " <timestamp>%s</timestamp>\n" |
cristy | 91f905a | 2010-06-03 01:01:32 +0000 | [diff] [blame] | 851 | " <elapsed-time>%lu:%02lu.%03lu</elapsed-time>\n" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 852 | " <user-time>%0.3f</user-time>\n" |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 853 | " <process-id>%.20g</process-id>\n" |
| 854 | " <thread-id>%.20g</thread-id>\n" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 855 | " <module>%s</module>\n" |
| 856 | " <function>%s</function>\n" |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 857 | " <line>%.20g</line>\n" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 858 | " <domain>%s</domain>\n" |
| 859 | " <event>%s</event>\n" |
cristy | 91f905a | 2010-06-03 01:01:32 +0000 | [diff] [blame] | 860 | "</entry>",timestamp,(unsigned long) (elapsed_time/60.0), |
| 861 | (unsigned long) floor(fmod(elapsed_time,60.0)),(unsigned long) |
| 862 | (1000.0*(elapsed_time-floor(elapsed_time))+0.5),user_time, |
| 863 | (double) getpid(),(double) GetMagickThreadSignature(),module,function, |
| 864 | (double) line,domain,event); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 865 | return(text); |
| 866 | } |
| 867 | /* |
| 868 | Translate event in "human readable" format. |
| 869 | */ |
| 870 | q=text; |
| 871 | for (p=log_info->format; *p != '\0'; p++) |
| 872 | { |
| 873 | *q='\0'; |
| 874 | if ((size_t) (q-text+MaxTextExtent) >= extent) |
| 875 | { |
| 876 | extent+=MaxTextExtent; |
| 877 | text=(char *) ResizeQuantumMemory(text,extent+MaxTextExtent, |
| 878 | sizeof(*text)); |
| 879 | if (text == (char *) NULL) |
| 880 | return((char *) NULL); |
| 881 | q=text+strlen(text); |
| 882 | } |
| 883 | /* |
| 884 | The format of the log is defined by embedding special format characters: |
| 885 | |
| 886 | %c client name |
| 887 | %d domain |
| 888 | %e event |
| 889 | %f function |
| 890 | %g generation |
| 891 | %l line |
| 892 | %m module |
| 893 | %n log name |
| 894 | %p process id |
| 895 | %r real CPU time |
| 896 | %t wall clock time |
| 897 | %u user CPU time |
| 898 | %v version |
| 899 | %% percent sign |
| 900 | \n newline |
| 901 | \r carriage return |
| 902 | */ |
| 903 | if ((*p == '\\') && (*(p+1) == 'r')) |
| 904 | { |
| 905 | *q++='\r'; |
| 906 | p++; |
| 907 | continue; |
| 908 | } |
| 909 | if ((*p == '\\') && (*(p+1) == 'n')) |
| 910 | { |
| 911 | *q++='\n'; |
| 912 | p++; |
| 913 | continue; |
| 914 | } |
| 915 | if (*p != '%') |
| 916 | { |
| 917 | *q++=(*p); |
| 918 | continue; |
| 919 | } |
| 920 | p++; |
| 921 | switch (*p) |
| 922 | { |
| 923 | case 'c': |
| 924 | { |
| 925 | q+=CopyMagickString(q,GetClientName(),extent); |
| 926 | break; |
| 927 | } |
| 928 | case 'd': |
| 929 | { |
| 930 | q+=CopyMagickString(q,domain,extent); |
| 931 | break; |
| 932 | } |
| 933 | case 'e': |
| 934 | { |
| 935 | q+=CopyMagickString(q,event,extent); |
| 936 | break; |
| 937 | } |
| 938 | case 'f': |
| 939 | { |
| 940 | q+=CopyMagickString(q,function,extent); |
| 941 | break; |
| 942 | } |
| 943 | case 'g': |
| 944 | { |
| 945 | if (log_info->generations == 0) |
| 946 | { |
| 947 | (void) CopyMagickString(q,"0",extent); |
| 948 | q++; |
| 949 | break; |
| 950 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 951 | q+=FormatLocaleString(q,extent,"%.20g",(double) (log_info->generation % |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 952 | log_info->generations)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 953 | break; |
| 954 | } |
| 955 | case 'l': |
| 956 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 957 | q+=FormatLocaleString(q,extent,"%.20g",(double) line); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 958 | break; |
| 959 | } |
| 960 | case 'm': |
| 961 | { |
| 962 | register const char |
| 963 | *p; |
| 964 | |
| 965 | for (p=module+strlen(module)-1; p > module; p--) |
| 966 | if (*p == *DirectorySeparator) |
| 967 | { |
| 968 | p++; |
| 969 | break; |
| 970 | } |
| 971 | q+=CopyMagickString(q,p,extent); |
| 972 | break; |
| 973 | } |
| 974 | case 'n': |
| 975 | { |
| 976 | q+=CopyMagickString(q,GetLogName(),extent); |
| 977 | break; |
| 978 | } |
| 979 | case 'p': |
| 980 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 981 | q+=FormatLocaleString(q,extent,"%.20g",(double) getpid()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 982 | break; |
| 983 | } |
| 984 | case 'r': |
| 985 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 986 | q+=FormatLocaleString(q,extent,"%lu:%02lu.%03lu",(unsigned long) |
cristy | 91f905a | 2010-06-03 01:01:32 +0000 | [diff] [blame] | 987 | (elapsed_time/60.0),(unsigned long) floor(fmod(elapsed_time,60.0)), |
| 988 | (unsigned long) (1000.0*(elapsed_time-floor(elapsed_time))+0.5)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 989 | break; |
| 990 | } |
| 991 | case 't': |
| 992 | { |
| 993 | q+=FormatMagickTime(seconds,extent,q); |
| 994 | break; |
| 995 | } |
| 996 | case 'u': |
| 997 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 998 | q+=FormatLocaleString(q,extent,"%0.3fu",user_time); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 999 | break; |
| 1000 | } |
| 1001 | case 'v': |
| 1002 | { |
| 1003 | q+=CopyMagickString(q,MagickLibVersionText,extent); |
| 1004 | break; |
| 1005 | } |
| 1006 | case '%': |
| 1007 | { |
| 1008 | *q++=(*p); |
| 1009 | break; |
| 1010 | } |
| 1011 | default: |
| 1012 | { |
| 1013 | *q++='%'; |
| 1014 | *q++=(*p); |
| 1015 | break; |
| 1016 | } |
| 1017 | } |
| 1018 | } |
| 1019 | *q='\0'; |
| 1020 | return(text); |
| 1021 | } |
| 1022 | |
| 1023 | static char *TranslateFilename(const LogInfo *log_info) |
| 1024 | { |
| 1025 | char |
| 1026 | *filename; |
| 1027 | |
| 1028 | register char |
| 1029 | *q; |
| 1030 | |
| 1031 | register const char |
| 1032 | *p; |
| 1033 | |
| 1034 | size_t |
| 1035 | extent; |
| 1036 | |
| 1037 | /* |
| 1038 | Translate event in "human readable" format. |
| 1039 | */ |
| 1040 | assert(log_info != (LogInfo *) NULL); |
| 1041 | assert(log_info->filename != (char *) NULL); |
| 1042 | filename=AcquireString((char *) NULL); |
| 1043 | extent=MaxTextExtent; |
| 1044 | q=filename; |
| 1045 | for (p=log_info->filename; *p != '\0'; p++) |
| 1046 | { |
| 1047 | *q='\0'; |
| 1048 | if ((size_t) (q-filename+MaxTextExtent) >= extent) |
| 1049 | { |
| 1050 | extent+=MaxTextExtent; |
| 1051 | filename=(char *) ResizeQuantumMemory(filename,extent+MaxTextExtent, |
| 1052 | sizeof(*filename)); |
| 1053 | if (filename == (char *) NULL) |
| 1054 | return((char *) NULL); |
| 1055 | q=filename+strlen(filename); |
| 1056 | } |
| 1057 | /* |
| 1058 | The format of the filename is defined by embedding special format |
| 1059 | characters: |
| 1060 | |
| 1061 | %c client name |
| 1062 | %n log name |
| 1063 | %p process id |
| 1064 | %v version |
| 1065 | %% percent sign |
| 1066 | */ |
| 1067 | if (*p != '%') |
| 1068 | { |
| 1069 | *q++=(*p); |
| 1070 | continue; |
| 1071 | } |
| 1072 | p++; |
| 1073 | switch (*p) |
| 1074 | { |
| 1075 | case 'c': |
| 1076 | { |
| 1077 | q+=CopyMagickString(q,GetClientName(),extent); |
| 1078 | break; |
| 1079 | } |
| 1080 | case 'g': |
| 1081 | { |
| 1082 | if (log_info->generations == 0) |
| 1083 | { |
| 1084 | (void) CopyMagickString(q,"0",extent); |
| 1085 | q++; |
| 1086 | break; |
| 1087 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1088 | q+=FormatLocaleString(q,extent,"%.20g",(double) (log_info->generation % |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1089 | log_info->generations)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1090 | break; |
| 1091 | } |
| 1092 | case 'n': |
| 1093 | { |
| 1094 | q+=CopyMagickString(q,GetLogName(),extent); |
| 1095 | break; |
| 1096 | } |
| 1097 | case 'p': |
| 1098 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1099 | q+=FormatLocaleString(q,extent,"%.20g",(double) getpid()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1100 | break; |
| 1101 | } |
| 1102 | case 'v': |
| 1103 | { |
| 1104 | q+=CopyMagickString(q,MagickLibVersionText,extent); |
| 1105 | break; |
| 1106 | } |
| 1107 | case '%': |
| 1108 | { |
| 1109 | *q++=(*p); |
| 1110 | break; |
| 1111 | } |
| 1112 | default: |
| 1113 | { |
| 1114 | *q++='%'; |
| 1115 | *q++=(*p); |
| 1116 | break; |
| 1117 | } |
| 1118 | } |
| 1119 | } |
| 1120 | *q='\0'; |
| 1121 | return(filename); |
| 1122 | } |
| 1123 | |
| 1124 | MagickBooleanType LogMagickEventList(const LogEventType type,const char *module, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1125 | const char *function,const size_t line,const char *format, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1126 | va_list operands) |
| 1127 | { |
| 1128 | char |
| 1129 | event[MaxTextExtent], |
| 1130 | *text; |
| 1131 | |
| 1132 | const char |
| 1133 | *domain; |
| 1134 | |
| 1135 | ExceptionInfo |
| 1136 | *exception; |
| 1137 | |
| 1138 | int |
| 1139 | n; |
| 1140 | |
| 1141 | LogInfo |
| 1142 | *log_info; |
| 1143 | |
| 1144 | if (IsEventLogging() == MagickFalse) |
| 1145 | return(MagickFalse); |
| 1146 | exception=AcquireExceptionInfo(); |
| 1147 | log_info=(LogInfo *) GetLogInfo("*",exception); |
| 1148 | exception=DestroyExceptionInfo(exception); |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 1149 | LockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1150 | if ((log_info->event_mask & type) == 0) |
| 1151 | { |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 1152 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1153 | return(MagickTrue); |
| 1154 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1155 | domain=CommandOptionToMnemonic(MagickLogEventOptions,type); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1156 | #if defined(MAGICKCORE_HAVE_VSNPRINTF) |
| 1157 | n=vsnprintf(event,MaxTextExtent,format,operands); |
| 1158 | #else |
| 1159 | n=vsprintf(event,format,operands); |
| 1160 | #endif |
| 1161 | if (n < 0) |
| 1162 | event[MaxTextExtent-1]='\0'; |
| 1163 | text=TranslateEvent(type,module,function,line,domain,event); |
| 1164 | if (text == (char *) NULL) |
| 1165 | { |
| 1166 | (void) ContinueTimer((TimerInfo *) &log_info->timer); |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 1167 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1168 | return(MagickFalse); |
| 1169 | } |
| 1170 | if ((log_info->handler_mask & ConsoleHandler) != 0) |
| 1171 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1172 | (void) FormatLocaleFile(stderr,"%s\n",text); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1173 | (void) fflush(stderr); |
| 1174 | } |
| 1175 | if ((log_info->handler_mask & DebugHandler) != 0) |
| 1176 | { |
cristy | 0157aea | 2010-04-24 21:12:18 +0000 | [diff] [blame] | 1177 | #if defined(MAGICKCORE_WINDOWS_SUPPORT) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1178 | OutputDebugString(text); |
cristy | 690a0eb | 2013-07-24 16:43:22 +0000 | [diff] [blame] | 1179 | OutputDebugString("\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1180 | #endif |
| 1181 | } |
| 1182 | if ((log_info->handler_mask & EventHandler) != 0) |
| 1183 | { |
cristy | 0157aea | 2010-04-24 21:12:18 +0000 | [diff] [blame] | 1184 | #if defined(MAGICKCORE_WINDOWS_SUPPORT) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1185 | (void) NTReportEvent(text,MagickFalse); |
| 1186 | #endif |
| 1187 | } |
| 1188 | if ((log_info->handler_mask & FileHandler) != 0) |
| 1189 | { |
| 1190 | struct stat |
| 1191 | file_info; |
| 1192 | |
| 1193 | file_info.st_size=0; |
| 1194 | if (log_info->file != (FILE *) NULL) |
| 1195 | (void) fstat(fileno(log_info->file),&file_info); |
cristy | 94b1183 | 2011-09-08 19:46:03 +0000 | [diff] [blame] | 1196 | if (file_info.st_size > (ssize_t) (1024*1024*log_info->limit)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1197 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1198 | (void) FormatLocaleFile(log_info->file,"</log>\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1199 | (void) fclose(log_info->file); |
| 1200 | log_info->file=(FILE *) NULL; |
| 1201 | } |
| 1202 | if (log_info->file == (FILE *) NULL) |
| 1203 | { |
| 1204 | char |
| 1205 | *filename; |
| 1206 | |
| 1207 | filename=TranslateFilename(log_info); |
| 1208 | if (filename == (char *) NULL) |
| 1209 | { |
| 1210 | (void) ContinueTimer((TimerInfo *) &log_info->timer); |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 1211 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1212 | return(MagickFalse); |
| 1213 | } |
| 1214 | log_info->append=IsPathAccessible(filename); |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 1215 | log_info->file=fopen_utf8(filename,"ab"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1216 | filename=(char *) RelinquishMagickMemory(filename); |
| 1217 | if (log_info->file == (FILE *) NULL) |
| 1218 | { |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 1219 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1220 | return(MagickFalse); |
| 1221 | } |
| 1222 | log_info->generation++; |
| 1223 | if (log_info->append == MagickFalse) |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 1224 | (void) FormatLocaleFile(log_info->file,"<?xml version=\"1.0\" " |
| 1225 | "encoding=\"UTF-8\" standalone=\"yes\"?>\n"); |
| 1226 | (void) FormatLocaleFile(log_info->file,"<log>\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1227 | } |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 1228 | (void) FormatLocaleFile(log_info->file," <event>%s</event>\n",text); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1229 | (void) fflush(log_info->file); |
| 1230 | } |
| 1231 | if ((log_info->handler_mask & StdoutHandler) != 0) |
| 1232 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1233 | (void) FormatLocaleFile(stdout,"%s\n",text); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1234 | (void) fflush(stdout); |
| 1235 | } |
| 1236 | if ((log_info->handler_mask & StderrHandler) != 0) |
| 1237 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1238 | (void) FormatLocaleFile(stderr,"%s\n",text); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1239 | (void) fflush(stderr); |
| 1240 | } |
| 1241 | text=(char *) RelinquishMagickMemory(text); |
| 1242 | (void) ContinueTimer((TimerInfo *) &log_info->timer); |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 1243 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1244 | return(MagickTrue); |
| 1245 | } |
| 1246 | |
| 1247 | MagickBooleanType LogMagickEvent(const LogEventType type,const char *module, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1248 | const char *function,const size_t line,const char *format,...) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1249 | { |
| 1250 | va_list |
| 1251 | operands; |
| 1252 | |
| 1253 | MagickBooleanType |
| 1254 | status; |
| 1255 | |
| 1256 | va_start(operands,format); |
| 1257 | status=LogMagickEventList(type,module,function,line,format,operands); |
| 1258 | va_end(operands); |
| 1259 | return(status); |
| 1260 | } |
| 1261 | |
| 1262 | /* |
| 1263 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1264 | % % |
| 1265 | % % |
| 1266 | % % |
| 1267 | + L o a d L o g L i s t % |
| 1268 | % % |
| 1269 | % % |
| 1270 | % % |
| 1271 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1272 | % |
| 1273 | % LoadLogList() loads the log configuration file which provides a |
| 1274 | % mapping between log attributes and log name. |
| 1275 | % |
| 1276 | % The format of the LoadLogList method is: |
| 1277 | % |
| 1278 | % MagickBooleanType LoadLogList(const char *xml,const char *filename, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1279 | % const size_t depth,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1280 | % |
| 1281 | % A description of each parameter follows: |
| 1282 | % |
| 1283 | % o xml: The log list in XML format. |
| 1284 | % |
| 1285 | % o filename: The log list filename. |
| 1286 | % |
| 1287 | % o depth: depth of <include /> statements. |
| 1288 | % |
| 1289 | % o exception: return any errors or warnings in this structure. |
| 1290 | % |
| 1291 | */ |
| 1292 | static MagickBooleanType LoadLogList(const char *xml,const char *filename, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1293 | const size_t depth,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1294 | { |
| 1295 | char |
| 1296 | keyword[MaxTextExtent], |
| 1297 | *token; |
| 1298 | |
| 1299 | const char |
| 1300 | *q; |
| 1301 | |
| 1302 | LogInfo |
| 1303 | *log_info = (LogInfo *) NULL; |
| 1304 | |
| 1305 | MagickStatusType |
| 1306 | status; |
| 1307 | |
| 1308 | /* |
| 1309 | Load the log map file. |
| 1310 | */ |
| 1311 | if (xml == (const char *) NULL) |
| 1312 | return(MagickFalse); |
| 1313 | if (log_list == (LinkedListInfo *) NULL) |
| 1314 | { |
| 1315 | log_list=NewLinkedList(0); |
| 1316 | if (log_list == (LinkedListInfo *) NULL) |
| 1317 | { |
| 1318 | ThrowFileException(exception,ResourceLimitError, |
| 1319 | "MemoryAllocationFailed",filename); |
| 1320 | return(MagickFalse); |
| 1321 | } |
| 1322 | } |
| 1323 | status=MagickTrue; |
| 1324 | token=AcquireString((const char *) xml); |
| 1325 | for (q=(const char *) xml; *q != '\0'; ) |
| 1326 | { |
| 1327 | /* |
| 1328 | Interpret XML. |
| 1329 | */ |
| 1330 | GetMagickToken(q,&q,token); |
| 1331 | if (*token == '\0') |
| 1332 | break; |
| 1333 | (void) CopyMagickString(keyword,token,MaxTextExtent); |
| 1334 | if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0) |
| 1335 | { |
| 1336 | /* |
| 1337 | Doctype element. |
| 1338 | */ |
| 1339 | while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0')) |
| 1340 | GetMagickToken(q,&q,token); |
| 1341 | continue; |
| 1342 | } |
| 1343 | if (LocaleNCompare(keyword,"<!--",4) == 0) |
| 1344 | { |
| 1345 | /* |
| 1346 | Comment element. |
| 1347 | */ |
| 1348 | while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0')) |
| 1349 | GetMagickToken(q,&q,token); |
| 1350 | continue; |
| 1351 | } |
| 1352 | if (LocaleCompare(keyword,"<include") == 0) |
| 1353 | { |
| 1354 | /* |
| 1355 | Include element. |
| 1356 | */ |
| 1357 | while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0')) |
| 1358 | { |
| 1359 | (void) CopyMagickString(keyword,token,MaxTextExtent); |
| 1360 | GetMagickToken(q,&q,token); |
| 1361 | if (*token != '=') |
| 1362 | continue; |
| 1363 | GetMagickToken(q,&q,token); |
| 1364 | if (LocaleCompare(keyword,"file") == 0) |
| 1365 | { |
| 1366 | if (depth > 200) |
| 1367 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 1368 | ConfigureError,"IncludeElementNestedTooDeeply","`%s'",token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1369 | else |
| 1370 | { |
| 1371 | char |
| 1372 | path[MaxTextExtent], |
| 1373 | *xml; |
| 1374 | |
| 1375 | GetPathComponent(filename,HeadPath,path); |
| 1376 | if (*path != '\0') |
| 1377 | (void) ConcatenateMagickString(path,DirectorySeparator, |
| 1378 | MaxTextExtent); |
| 1379 | if (*token == *DirectorySeparator) |
| 1380 | (void) CopyMagickString(path,token,MaxTextExtent); |
| 1381 | else |
| 1382 | (void) ConcatenateMagickString(path,token,MaxTextExtent); |
cristy | 3a5987c | 2013-11-07 14:18:46 +0000 | [diff] [blame] | 1383 | xml=FileToString(path,~0UL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1384 | if (xml != (char *) NULL) |
| 1385 | { |
cristy | aae13f6 | 2013-08-15 14:41:32 +0000 | [diff] [blame] | 1386 | status&=LoadLogList(xml,path,depth+1,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1387 | xml=DestroyString(xml); |
| 1388 | } |
| 1389 | } |
| 1390 | } |
| 1391 | } |
| 1392 | continue; |
| 1393 | } |
| 1394 | if (LocaleCompare(keyword,"<logmap>") == 0) |
| 1395 | { |
| 1396 | /* |
| 1397 | Allocate memory for the log list. |
| 1398 | */ |
cristy | 73bd4a5 | 2010-10-05 11:24:23 +0000 | [diff] [blame] | 1399 | log_info=(LogInfo *) AcquireMagickMemory(sizeof(*log_info)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1400 | if (log_info == (LogInfo *) NULL) |
| 1401 | ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); |
| 1402 | (void) ResetMagickMemory(log_info,0,sizeof(*log_info)); |
| 1403 | log_info->path=ConstantString(filename); |
| 1404 | GetTimerInfo((TimerInfo *) &log_info->timer); |
| 1405 | log_info->signature=MagickSignature; |
| 1406 | continue; |
| 1407 | } |
| 1408 | if (log_info == (LogInfo *) NULL) |
| 1409 | continue; |
| 1410 | if (LocaleCompare(keyword,"</logmap>") == 0) |
| 1411 | { |
| 1412 | status=AppendValueToLinkedList(log_list,log_info); |
| 1413 | if (status == MagickFalse) |
| 1414 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 1415 | ResourceLimitError,"MemoryAllocationFailed","`%s'",filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1416 | log_info=(LogInfo *) NULL; |
| 1417 | } |
| 1418 | GetMagickToken(q,(const char **) NULL,token); |
| 1419 | if (*token != '=') |
| 1420 | continue; |
| 1421 | GetMagickToken(q,&q,token); |
| 1422 | GetMagickToken(q,&q,token); |
| 1423 | switch (*keyword) |
| 1424 | { |
| 1425 | case 'E': |
| 1426 | case 'e': |
| 1427 | { |
| 1428 | if (LocaleCompare((char *) keyword,"events") == 0) |
| 1429 | { |
| 1430 | log_info->event_mask=(LogEventType) (log_info->event_mask | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1431 | ParseCommandOption(MagickLogEventOptions,MagickTrue,token)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1432 | break; |
| 1433 | } |
| 1434 | break; |
| 1435 | } |
| 1436 | case 'F': |
| 1437 | case 'f': |
| 1438 | { |
| 1439 | if (LocaleCompare((char *) keyword,"filename") == 0) |
| 1440 | { |
| 1441 | if (log_info->filename != (char *) NULL) |
| 1442 | log_info->filename=(char *) |
| 1443 | RelinquishMagickMemory(log_info->filename); |
| 1444 | log_info->filename=ConstantString(token); |
| 1445 | break; |
| 1446 | } |
| 1447 | if (LocaleCompare((char *) keyword,"format") == 0) |
| 1448 | { |
| 1449 | if (log_info->format != (char *) NULL) |
| 1450 | log_info->format=(char *) |
| 1451 | RelinquishMagickMemory(log_info->format); |
| 1452 | log_info->format=ConstantString(token); |
| 1453 | break; |
| 1454 | } |
| 1455 | break; |
| 1456 | } |
| 1457 | case 'G': |
| 1458 | case 'g': |
| 1459 | { |
| 1460 | if (LocaleCompare((char *) keyword,"generations") == 0) |
| 1461 | { |
| 1462 | if (LocaleCompare(token,"unlimited") == 0) |
| 1463 | { |
| 1464 | log_info->generations=(~0UL); |
| 1465 | break; |
| 1466 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1467 | log_info->generations=StringToUnsignedLong(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1468 | break; |
| 1469 | } |
| 1470 | break; |
| 1471 | } |
| 1472 | case 'L': |
| 1473 | case 'l': |
| 1474 | { |
| 1475 | if (LocaleCompare((char *) keyword,"limit") == 0) |
| 1476 | { |
| 1477 | if (LocaleCompare(token,"unlimited") == 0) |
| 1478 | { |
| 1479 | log_info->limit=(~0UL); |
| 1480 | break; |
| 1481 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1482 | log_info->limit=StringToUnsignedLong(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1483 | break; |
| 1484 | } |
| 1485 | break; |
| 1486 | } |
| 1487 | case 'O': |
| 1488 | case 'o': |
| 1489 | { |
| 1490 | if (LocaleCompare((char *) keyword,"output") == 0) |
| 1491 | { |
| 1492 | log_info->handler_mask=(LogHandlerType) |
| 1493 | (log_info->handler_mask | ParseLogHandlers(token)); |
| 1494 | break; |
| 1495 | } |
| 1496 | break; |
| 1497 | } |
| 1498 | default: |
| 1499 | break; |
| 1500 | } |
| 1501 | } |
| 1502 | token=DestroyString(token); |
| 1503 | if (log_list == (LinkedListInfo *) NULL) |
| 1504 | return(MagickFalse); |
| 1505 | return(status != 0 ? MagickTrue : MagickFalse); |
| 1506 | } |
| 1507 | |
| 1508 | /* |
| 1509 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1510 | % % |
| 1511 | % % |
| 1512 | % % |
| 1513 | % L o a d L o g L i s t s % |
| 1514 | % % |
| 1515 | % % |
| 1516 | % % |
| 1517 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1518 | % |
| 1519 | % LoadLogLists() loads one or more log configuration file which provides a |
| 1520 | % mapping between log attributes and log name. |
| 1521 | % |
| 1522 | % The format of the LoadLogLists method is: |
| 1523 | % |
| 1524 | % MagickBooleanType LoadLogLists(const char *filename, |
| 1525 | % ExceptionInfo *exception) |
| 1526 | % |
| 1527 | % A description of each parameter follows: |
| 1528 | % |
| 1529 | % o filename: the log configuration filename. |
| 1530 | % |
| 1531 | % o exception: return any errors or warnings in this structure. |
| 1532 | % |
| 1533 | */ |
| 1534 | static MagickBooleanType LoadLogLists(const char *filename, |
| 1535 | ExceptionInfo *exception) |
| 1536 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1537 | const StringInfo |
| 1538 | *option; |
| 1539 | |
| 1540 | LinkedListInfo |
| 1541 | *options; |
| 1542 | |
| 1543 | MagickStatusType |
| 1544 | status; |
| 1545 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1546 | register ssize_t |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 1547 | i; |
| 1548 | |
| 1549 | /* |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 1550 | Load external log map. |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 1551 | */ |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 1552 | if (log_list == (LinkedListInfo *) NULL) |
| 1553 | { |
| 1554 | log_list=NewLinkedList(0); |
| 1555 | if (log_list == (LinkedListInfo *) NULL) |
| 1556 | { |
| 1557 | ThrowFileException(exception,ResourceLimitError, |
| 1558 | "MemoryAllocationFailed",filename); |
| 1559 | return(MagickFalse); |
| 1560 | } |
| 1561 | } |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 1562 | status=MagickTrue; |
| 1563 | options=GetConfigureOptions(filename,exception); |
| 1564 | option=(const StringInfo *) GetNextValueInLinkedList(options); |
| 1565 | while (option != (const StringInfo *) NULL) |
| 1566 | { |
cristy | aae13f6 | 2013-08-15 14:41:32 +0000 | [diff] [blame] | 1567 | status&=LoadLogList((const char *) GetStringInfoDatum(option), |
cristy | 398fd02 | 2013-06-26 23:08:33 +0000 | [diff] [blame] | 1568 | GetStringInfoPath(option),0,exception); |
| 1569 | option=(const StringInfo *) GetNextValueInLinkedList(options); |
| 1570 | } |
| 1571 | options=DestroyConfigureOptions(options); |
| 1572 | /* |
| 1573 | Load built-in log map. |
| 1574 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1575 | for (i=0; i < (ssize_t) (sizeof(LogMap)/sizeof(*LogMap)); i++) |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 1576 | { |
| 1577 | LogInfo |
| 1578 | *log_info; |
| 1579 | |
| 1580 | register const LogMapInfo |
| 1581 | *p; |
| 1582 | |
| 1583 | p=LogMap+i; |
cristy | 73bd4a5 | 2010-10-05 11:24:23 +0000 | [diff] [blame] | 1584 | log_info=(LogInfo *) AcquireMagickMemory(sizeof(*log_info)); |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 1585 | if (log_info == (LogInfo *) NULL) |
| 1586 | { |
| 1587 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 1588 | ResourceLimitError,"MemoryAllocationFailed","`%s'",log_info->name); |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 1589 | continue; |
| 1590 | } |
| 1591 | (void) ResetMagickMemory(log_info,0,sizeof(*log_info)); |
cristy | 5965b49 | 2013-08-17 14:04:22 +0000 | [diff] [blame] | 1592 | log_info->path=ConstantString("[built-in]"); |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 1593 | GetTimerInfo((TimerInfo *) &log_info->timer); |
| 1594 | log_info->event_mask=p->event_mask; |
| 1595 | log_info->handler_mask=p->handler_mask; |
cristy | 5aaf574 | 2009-11-22 00:56:44 +0000 | [diff] [blame] | 1596 | log_info->filename=ConstantString(p->filename); |
| 1597 | log_info->format=ConstantString(p->format); |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 1598 | log_info->signature=MagickSignature; |
cristy | aae13f6 | 2013-08-15 14:41:32 +0000 | [diff] [blame] | 1599 | status&=AppendValueToLinkedList(log_list,log_info); |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 1600 | if (status == MagickFalse) |
| 1601 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 1602 | ResourceLimitError,"MemoryAllocationFailed","`%s'",log_info->name); |
cristy | 8534029 | 2009-10-21 19:32:19 +0000 | [diff] [blame] | 1603 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1604 | return(status != 0 ? MagickTrue : MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | /* |
| 1608 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1609 | % % |
| 1610 | % % |
| 1611 | % % |
| 1612 | + P a r s e L o g H a n d l e r s % |
| 1613 | % % |
| 1614 | % % |
| 1615 | % % |
| 1616 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1617 | % |
| 1618 | % ParseLogHandlers() parses a string defining which handlers takes a log |
| 1619 | % message and exports them. |
| 1620 | % |
| 1621 | % The format of the ParseLogHandlers method is: |
| 1622 | % |
| 1623 | % LogHandlerType ParseLogHandlers(const char *handlers) |
| 1624 | % |
| 1625 | % A description of each parameter follows: |
| 1626 | % |
| 1627 | % o handlers: one or more handlers separated by commas. |
| 1628 | % |
| 1629 | */ |
| 1630 | static LogHandlerType ParseLogHandlers(const char *handlers) |
| 1631 | { |
| 1632 | LogHandlerType |
| 1633 | handler_mask; |
| 1634 | |
| 1635 | register const char |
| 1636 | *p; |
| 1637 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1638 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1639 | i; |
| 1640 | |
| 1641 | size_t |
| 1642 | length; |
| 1643 | |
| 1644 | handler_mask=NoHandler; |
| 1645 | for (p=handlers; p != (char *) NULL; p=strchr(p,',')) |
| 1646 | { |
| 1647 | while ((*p != '\0') && ((isspace((int) ((unsigned char) *p)) != 0) || |
| 1648 | (*p == ','))) |
| 1649 | p++; |
| 1650 | for (i=0; LogHandlers[i].name != (char *) NULL; i++) |
| 1651 | { |
| 1652 | length=strlen(LogHandlers[i].name); |
| 1653 | if (LocaleNCompare(p,LogHandlers[i].name,length) == 0) |
| 1654 | { |
| 1655 | handler_mask=(LogHandlerType) (handler_mask | LogHandlers[i].handler); |
| 1656 | break; |
| 1657 | } |
| 1658 | } |
| 1659 | if (LogHandlers[i].name == (char *) NULL) |
| 1660 | return(UndefinedHandler); |
| 1661 | } |
| 1662 | return(handler_mask); |
| 1663 | } |
| 1664 | |
| 1665 | /* |
| 1666 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1667 | % % |
| 1668 | % % |
| 1669 | % % |
| 1670 | % S e t L o g E v e n t M a s k % |
| 1671 | % % |
| 1672 | % % |
| 1673 | % % |
| 1674 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1675 | % |
| 1676 | % SetLogEventMask() accepts a list that determines which events to log. All |
| 1677 | % other events are ignored. By default, no debug is enabled. This method |
| 1678 | % returns the previous log event mask. |
| 1679 | % |
| 1680 | % The format of the SetLogEventMask method is: |
| 1681 | % |
| 1682 | % LogEventType SetLogEventMask(const char *events) |
| 1683 | % |
| 1684 | % A description of each parameter follows: |
| 1685 | % |
| 1686 | % o events: log these events. |
| 1687 | % |
| 1688 | */ |
| 1689 | MagickExport LogEventType SetLogEventMask(const char *events) |
| 1690 | { |
| 1691 | ExceptionInfo |
| 1692 | *exception; |
| 1693 | |
| 1694 | LogInfo |
| 1695 | *log_info; |
| 1696 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1697 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1698 | option; |
| 1699 | |
| 1700 | exception=AcquireExceptionInfo(); |
| 1701 | log_info=(LogInfo *) GetLogInfo("*",exception); |
| 1702 | exception=DestroyExceptionInfo(exception); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1703 | option=ParseCommandOption(MagickLogEventOptions,MagickTrue,events); |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 1704 | LockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1705 | log_info=(LogInfo *) GetValueFromLinkedList(log_list,0); |
| 1706 | log_info->event_mask=(LogEventType) option; |
| 1707 | if (option == -1) |
| 1708 | log_info->event_mask=UndefinedEvents; |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 1709 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1710 | return(log_info->event_mask); |
| 1711 | } |
| 1712 | |
| 1713 | /* |
| 1714 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1715 | % % |
| 1716 | % % |
| 1717 | % % |
| 1718 | % S e t L o g F o r m a t % |
| 1719 | % % |
| 1720 | % % |
| 1721 | % % |
| 1722 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1723 | % |
| 1724 | % SetLogFormat() sets the format for the "human readable" log record. |
| 1725 | % |
| 1726 | % The format of the LogMagickFormat method is: |
| 1727 | % |
| 1728 | % SetLogFormat(const char *format) |
| 1729 | % |
| 1730 | % A description of each parameter follows: |
| 1731 | % |
| 1732 | % o format: the log record format. |
| 1733 | % |
| 1734 | */ |
| 1735 | MagickExport void SetLogFormat(const char *format) |
| 1736 | { |
| 1737 | LogInfo |
| 1738 | *log_info; |
| 1739 | |
| 1740 | ExceptionInfo |
| 1741 | *exception; |
| 1742 | |
| 1743 | exception=AcquireExceptionInfo(); |
| 1744 | log_info=(LogInfo *) GetLogInfo("*",exception); |
| 1745 | exception=DestroyExceptionInfo(exception); |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 1746 | LockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1747 | if (log_info->format != (char *) NULL) |
| 1748 | log_info->format=DestroyString(log_info->format); |
| 1749 | log_info->format=ConstantString(format); |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 1750 | UnlockSemaphoreInfo(log_semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1751 | } |
| 1752 | |
| 1753 | /* |
| 1754 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1755 | % % |
| 1756 | % % |
| 1757 | % % |
| 1758 | % S e t L o g N a m e % |
| 1759 | % % |
| 1760 | % % |
| 1761 | % % |
| 1762 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1763 | % |
| 1764 | % SetLogName() sets the log name and returns it. |
| 1765 | % |
| 1766 | % The format of the SetLogName method is: |
| 1767 | % |
| 1768 | % const char *SetLogName(const char *name) |
| 1769 | % |
| 1770 | % A description of each parameter follows: |
| 1771 | % |
| 1772 | % o log_name: SetLogName() returns the current client name. |
| 1773 | % |
| 1774 | % o name: Specifies the new client name. |
| 1775 | % |
| 1776 | */ |
| 1777 | MagickExport const char *SetLogName(const char *name) |
| 1778 | { |
| 1779 | if ((name != (char *) NULL) && (*name != '\0')) |
| 1780 | (void) CopyMagickString(log_name,name,MaxTextExtent); |
| 1781 | return(log_name); |
| 1782 | } |