1 /*
2   Copyright (C) 2003 - 2020 GraphicsMagick Group
3   Copyright (C) 2002 ImageMagick Studio
4 
5   This program is covered by multiple licenses, which are described in
6   Copyright.txt. You should have received a copy of Copyright.txt with this
7   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
8 
9   Log methods.
10 */
11 #ifndef _MAGICK_LOG_H
12 #define _MAGICK_LOG_H
13 
14 #include "magick/error.h"
15 
16 #if defined(__cplusplus) || defined(c_plusplus)
17 extern "C" {
18 #endif
19 
20   /*
21     Define declarations.
22   */
23 #define MagickLogFilename  "log.mgk"
24 
25   /*
26     Obtain the current C function name (if possible)
27   */
28 #  if !defined(GetCurrentFunction)
29 #    if (((defined(__cplusplus) || defined(c_plusplus)) && defined(HAS_CPP__func__)) || \
30         (!(defined(__cplusplus) || defined(c_plusplus)) && defined(HAS_C__func__)))
31 #      define GetCurrentFunction() (__func__)
32 #    elif defined(_VISUALC_) && defined(__FUNCTION__)
33 #      define GetCurrentFunction() (__FUNCTION__)
34 #    else
35 #      define GetCurrentFunction() ("unknown")
36 #    endif
37 #  endif
38 
39   /*
40     Obtain current source file, function name, and source file line,
41     in a form acceptable for use with LogMagickEvent.
42   */
43 #  if !defined(GetMagickModule)
44 #    define GetMagickModule()  __FILE__,GetCurrentFunction(),__LINE__
45 #  endif
46 
47 
48 /* NOTE: any changes to this effect PerlMagick */
49 typedef enum
50 {
51   UndefinedEventMask     = 0x00000000,
52   NoEventsMask           = 0x00000000,
53   ConfigureEventMask     = 0x00000001,
54   AnnotateEventMask      = 0x00000002,
55   RenderEventMask        = 0x00000004,
56   TransformEventMask     = 0x00000008,
57   LocaleEventMask        = 0x00000010,
58   CoderEventMask         = 0x00000020,
59   X11EventMask           = 0x00000040,
60   CacheEventMask         = 0x00000080,
61   BlobEventMask          = 0x00000100,
62   DeprecateEventMask     = 0x00000200,
63   UserEventMask          = 0x00000400,
64   ResourceEventMask      = 0x00000800,
65   TemporaryFileEventMask = 0x00001000,
66   /* ExceptionEventMask = WarningEventMask | ErrorEventMask |  FatalErrorEventMask */
67   ExceptionEventMask     = 0x00070000,
68   OptionEventMask        = 0x00004000,
69   InformationEventMask   = 0x00008000,
70   WarningEventMask       = 0x00010000,
71   ErrorEventMask         = 0x00020000,
72   FatalErrorEventMask    = 0x00040000,
73   AllEventsMask          = 0x7FFFFFFF
74 } LogEventType;
75 
76 /*
77   Typedef declarations.
78 */
79 typedef enum
80 {
81   DisabledOutput         = 0x0000,
82   UndefinedOutput        = 0x0000,
83   StdoutOutput           = 0x0001,
84   StderrOutput           = 0x0002,
85   XMLFileOutput          = 0x0004,
86   TXTFileOutput          = 0x0008,
87   Win32DebugOutput       = 0x0010,
88   Win32EventlogOutput    = 0x0020,
89   MethodOutput           = 0x0040
90 } LogOutputType;
91 
92 typedef void
93   (*LogMethod)(const ExceptionType type,const char *text);
94 
95 /*
96   Method declarations.
97 */
98 extern MagickExport MagickBool
99   IsEventLogging(void) MAGICK_FUNC_PURE,
100   LogMagickEvent(const ExceptionType type,
101     const char *module,const char *function,const unsigned long line,
102     const char *format,...) MAGICK_ATTRIBUTE((__format__ (__printf__,5,6))),
103   LogMagickEventList(const ExceptionType type,
104     const char *module,const char *function,const unsigned long line,
105     const char *format,va_list operands) MAGICK_ATTRIBUTE((__format__ (__printf__,5,0)));
106 
107 extern MagickExport unsigned long
108   SetLogEventMask(const char *events);
109 
110 extern MagickExport void
111   SetLogDefaultEventType(const char *events),
112   SetLogDefaultGenerations(const unsigned long generations),
113   SetLogDefaultLimit(const unsigned long limit),
114   SetLogDefaultFileName( const char *filename ),
115   SetLogDefaultFormat( const char *format ),
116   SetLogDefaultLogMethod(const LogMethod method),
117   SetLogDefaultOutputType(const LogOutputType output_type),
118   SetLogFormat(const char *format),
119   SetLogMethod(LogMethod);
120 
121 #if defined(MAGICK_IMPLEMENTATION)
122 #  include "magick/log-private.h"
123 #endif /* MAGICK_IMPLEMENTATION */
124 
125 #if defined(__cplusplus) || defined(c_plusplus)
126 }
127 #endif
128 
129 #endif /* _MAGICK_LOG_H */
130 
131 /*
132  * Local Variables:
133  * mode: c
134  * c-basic-offset: 2
135  * fill-column: 78
136  * End:
137  */
138