ewPrint(long source,long type,char *file,long line,long logger,char *format,va_list ap)
ewPrint()
will format an error/log message and output it using the global
EW_Output ewGlobalOutput or through the standard
WBA_Logger mechanism, the latter if logger is non-zero.
For a non-zero logger,
format is followed by a variable number of arguments which are
eventually fed into a near-equivalant of printf().
Note that you should be careful not to unintentially use
printf()-style
formatting character sequences.
For a logger of zero,
variable arguments are ignored and format is considered a fixed message.
For specific control and consistant responses, the following enumerations for
source should be used:
| EW_APP |
Incident occured in the application itself.
|
| EW_GFX |
Incident occured in the graphics abstraction.
|
| EW_WINDOW |
Incident occured in the window handling.
|
| EW_EVENT |
Incident occured in the event handling.
|
| EW_EW |
Incident occured in EW (non-specific).
|
| EW_OS |
Incident occured with the Operating System.
|
| EW_WIDGET |
Incident occured in the widget library.
|
The following enumerations for type should be used:
| EW_LOG |
Just information, no real problem.
|
| EW_WARN |
This incident may cause inaccuracies or future problems.
|
| EW_ERROR |
This incident will probably cause undesired behavior or additional failures.
|
| EW_FATAL |
A unrecoverable problem has occured.
This currently initiates an equivalent of exit() .
|
| EW_CRASH |
An intential crash is requested, presumably for debugging.
This currently initiates a segmentation fault,
usually followed by a core dump or debugger break. (uses *((long *)0)=0) |
The message is text describing the specific problem,
preferably stating the function/member in which it occured.
The file and line are the source file and line number where
ewPrint() is called.
The macro EW_PRINT() determines these automatically and calls
ewPrint() .
Additional output formatting is defined in the function ewPrint() itself.
This may include OS-dependent error states/messages and
secondary actions (such as exit() for EW_FATAL).
The output modes can be customized using the EW_Output member functions of
ewGlobalOutput .
EW_PRINT(EW_EVENT,EW_WARN,"negative index %d",index) EW_PRINT(EW_GFX,EW_ERROR,"EW_Window::SetFont(): could not set text alignment") EW_PRINT(EW_WINDOW,EW_FATAL,"cannot connect to X server")
Non-log calls to ewPrint can clear errno.
If the application needs to use errno,
it should read the value prior to calling EW_PRINT().
Many messages originating from within EW and WDS such as widget dumps
are upwards to 200 characters wide.
Although any terminal width can be used,
a 200 column shell is probably clearer.
Many messages optionally use ANSI color codes to clarify complex text
or point out important information.
White and black are available, but not used, since these are
the common background colors.
By default, terminal text coloring is on for UNIX and off for Win32.