-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to the libUseful RaiseError system
- Loading branch information
1 parent
05f5169
commit d5a8841
Showing
2 changed files
with
68 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ Copyright (c) 2015 Colum Paget <[email protected]> | |
#define ERRFLAG_ERRNO 1 | ||
#define ERRFLAG_DEBUG 2 | ||
#define ERRFLAG_CLEAR 4 | ||
#define ERRFLAG_NOTTY 8 | ||
|
||
|
||
/* | ||
|
@@ -41,14 +42,34 @@ Errors are injected into the list with RaiseError like this: | |
the system when RaiseError was called. Also, if RaiseError prints out an error, then the string description of | ||
errno, as obtained from strerror will be appended to the output message. | ||
If the flag ERRFLAG_DEBUG is set then RaiseError won't print anything out unless the environment variable | ||
'LIBUSEFUL_DEBUG' is set (to any value) or the libUseful internal value 'Error:Debug' has been set to 'true' (or | ||
'y' or 'yes') with LibUsefulSetValue. If ERRFLAG_DEBUG is passed then nothing is EVER added to the ErrorList. | ||
Bye default RaiseError will not print out to stderr if stderr is not a tty, in order to prevent sending errors | ||
up pipes and sockets to applications that aren't expecting them. If you want raise error to print even when | ||
stderr is not a tty then either pass the ERRFLAG_NOTTY value, like this | ||
RaiseError(ERRFLAG_ERRNO|ERRFLAG_NOTTY, "ServiceConnect", "host=%s port=%d",Host, Port); | ||
or, if you don't want to have to do this every time you call RaiseError, then you can achieve the same by | ||
setting the libUseful internal boolean value 'Error:notty', like this: | ||
ListUsefulSetValue("Error:notty","Y") | ||
If the flag ERRFLAG_DEBUG is set then RaiseError won't print anything out by default. So this line: | ||
RaiseError(ERRFLAG_DEBUG, "ServiceConnect", "host=%s port=%d",Host, Port); | ||
Wouldn't produce any output normally. This allows you to have debugging lines that can be switched on as | ||
needed. There's two ways to activate debugging. Firstly there's the environment variable 'LIBUSEFUL_DEBUG'. | ||
When this environment variable exists and is non-empty then RaiseError calls will print out, even if they're | ||
passed ERRFLAG_DEBUG. Secondly there's the libuseful internal value 'Error:Debug'. When this has been set to | ||
'true' (or 'y' or 'yes') with LibUsefulSetValue, then again all debugging lines will print out. | ||
If ERRFLAG_DEBUG is passed then nothing is EVER added to the ErrorList, the 'error' is just a debugging line | ||
and it's assumed that the program continues normally. | ||
If the libUseful internal value 'Error:Silent' is set true/yes/y with ListUsefulSetValue then RaiseError never | ||
prints errors to stderr. If the value 'Error:Syslog' is set true/yes/y then error and debug messages are sent | ||
to the system logger via syslog | ||
prints errors to stderr, regardless of any other config. | ||
If the value 'Error:Syslog' is set true/yes/y then error and debug messages are sent to the system logger via syslog | ||
*/ | ||
|
||
|
||
|