NCBI C++ ToolKit
|
Defines NCBI C++ diagnostic APIs, classes, and macros. More...
#include <corelib/ncbi_stack.hpp>
#include <deque>
#include <vector>
#include <map>
#include <atomic>
#include <stdexcept>
#include <corelib/ncbidiag.inl>
Go to the source code of this file.
Go to the SVN repository for this file.
Macros | |
#define | NCBI_CURRENT_FUNCTION NCBI_NS_NCBI::g_DiagUnknownFunction() |
Get current function name. More... | |
#define | NCBI_MAKE_MODULE(module) NCBI_AS_STRING(module) |
Set default module name based on NCBI_MODULE macro. More... | |
#define | DIAG_COMPILE_INFO |
Make compile time diagnostic information object to use in CNcbiDiag and CException. More... | |
#define | ERR_POST(message) |
Error posting with file, line number information but without error codes. More... | |
#define | SEVERITY_POST(severity, message) |
Wrappers for ERR_POST family of macros checking if the desired severity is enabled. More... | |
#define | WARNING_POST(message) SEVERITY_POST(Warning, message) |
#define | INFO_POST(message) SEVERITY_POST(Info, message) |
#define | TRACE_POST(message) SEVERITY_POST(Trace, message) |
#define | SEVERITY_POST_X(severity, subcode, message) |
#define | WARNING_POST_X(subcode, message) SEVERITY_POST_X(Warning, subcode, message) |
#define | INFO_POST_X(subcode, message) SEVERITY_POST_X(Info, subcode, message) |
#define | TRACE_POST_X(subcode, message) SEVERITY_POST_X(Trace, subcode, message) |
#define | SEVERITY_POST_EX(severity, errcode, subcode, message) |
#define | WARNING_POST_EX(errcode, subcode, message) SEVERITY_POST_EX(Warning, errcode, subcode, message) |
#define | INFO_POST_EX(errcode, message) SEVERITY_POST_EX(Info, errcode, subcode, message) |
#define | TRACE_POST_EX(errcode, message) SEVERITY_POST_EX(Trace, errcode, subcode, message) |
#define | LOG_POST(message) |
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro LOG_POST_X to make possible more flexible error statistics and logging. More... | |
#define | ERR_FATAL(message) |
Posting fatal error and abort. More... | |
#define | ERR_POST_EX(err_code, err_subcode, message) |
Error posting with error codes. More... | |
#define | LOG_POST_EX(err_code, err_subcode, message) |
#define | ERR_FATAL_EX(err_code, err_subcode, message) |
#define | NCBI_DEFINE_ERRCODE_X(name, err_code, max_err_subcode) |
Define global error code name with given value (err_code) and given maximum value of error subcode within this code. More... | |
#define | NCBI_DEFINE_ERR_SUBCODE_X(max_err_subcode) NCBI_DEFINE_ERR_SUBCODE_XX(NCBI_USE_ERRCODE_X, max_err_subcode) |
Define maximum value of subcode for the error code currently in use. More... | |
#define | NCBI_DEFINE_ERR_SUBCODE_XX(name, max_err_subcode) |
Define maximum value of subcode for particular error code name. More... | |
#define | NCBI_ERRCODE_X_NAME(name) NCBI_NS_NCBI::err_code_x::NCBI_NAME2(eErrCodeX_, name) |
Returns value of error code by its name defined by NCBI_DEFINE_ERRCODE_X. More... | |
#define | NCBI_ERRCODE_X NCBI_ERRCODE_X_NAME(NCBI_USE_ERRCODE_X) |
Returns currently set default error code. More... | |
#define | NCBI_MAX_ERR_SUBCODE_X_NAME(name) NCBI_NS_NCBI::err_code_x::NCBI_NAME2(SErrCodeX_Max_, name)<true>::value |
Returns maximum value of error subcode within error code with given name. More... | |
#define | NCBI_MAX_ERR_SUBCODE_X NCBI_MAX_ERR_SUBCODE_X_NAME(NCBI_USE_ERRCODE_X) |
Returns maximum value of error subcode within current default error code. More... | |
#define | NCBI_CHECK_ERRCODE_USAGE(name) |
Check that NCBI_DEFINE_ERR_SUBCODE_X is used for correctly defined error code. More... | |
#define | NCBI_CHECK_ERR_SUBCODE_X_NAME(name, subcode) |
Issue compile-time error if error subcode given is not valid for given error code name. More... | |
#define | NCBI_CHECK_ERR_SUBCODE_X(subcode) NCBI_CHECK_ERR_SUBCODE_X_NAME(NCBI_USE_ERRCODE_X, subcode) |
Issue compile-time error if error subcode given is not valid for current error code. More... | |
#define | NCBI_ERR_SUBCODE_X_NAME(name, subcode) (NCBI_CHECK_ERR_SUBCODE_X_NAME(name, subcode), subcode) |
Pass subcode as argument with check of its validity for given error code. More... | |
#define | NCBI_ERR_SUBCODE_X(subcode) (NCBI_CHECK_ERR_SUBCODE_X(subcode), subcode) |
Pass subcode as argument with check of its validity for current error code. More... | |
#define | ERR_POST_X(err_subcode, message) ERR_POST_XX(NCBI_USE_ERRCODE_X, err_subcode, message) |
Error posting with default error code and given error subcode. More... | |
#define | LOG_POST_X(err_subcode, message) LOG_POST_XX(NCBI_USE_ERRCODE_X, err_subcode, message) |
#define | ERR_FATAL_X(err_subcode, message) ERR_FATAL_XX(NCBI_USE_ERRCODE_X, err_subcode, message) |
#define | ERR_POST_XX(error_name, err_subcode, message) |
Error posting with error code having given name and with given error subcode. More... | |
#define | LOG_POST_XX(error_name, err_subcode, message) |
#define | ERR_FATAL_XX(error_name, err_subcode, message) |
#define | NCBI_REPEAT_POST_N_TIMES(post_macro, count, params) |
Common code for making log or error posting only given number of times during program execution. More... | |
#define | ERR_POST_N_TIMES(count, message) NCBI_REPEAT_POST_N_TIMES( ERR_POST, count, (message) ) |
Error posting only given number of times during program execution. More... | |
#define | LOG_POST_N_TIMES(count, message) NCBI_REPEAT_POST_N_TIMES( LOG_POST, count, (message) ) |
#define | ERR_POST_ONCE(message) ERR_POST_N_TIMES(1, message) |
Error posting only once during program execution. More... | |
#define | LOG_POST_ONCE(message) LOG_POST_N_TIMES(1, message) |
#define | ERR_POST_X_N_TIMES(count, err_subcode, message) NCBI_REPEAT_POST_N_TIMES( ERR_POST_X, count, (err_subcode, message) ) |
Error posting only given number of times during program execution with default error code and given error subcode. More... | |
#define | LOG_POST_X_N_TIMES(count, err_subcode, message) NCBI_REPEAT_POST_N_TIMES( LOG_POST_X, count, (err_subcode, message) ) |
#define | ERR_POST_X_ONCE(err_subcode, message) ERR_POST_X_N_TIMES(1, err_subcode, message) |
Error posting only once during program execution with default error code and given error subcode. More... | |
#define | LOG_POST_X_ONCE(err_subcode, message) LOG_POST_X_N_TIMES(1, err_subcode, message) |
#define | ERR_POST_XX_N_TIMES(count, error_name, err_subcode, message) |
Error posting only given number of times during program execution with given error code name and given error subcode. More... | |
#define | LOG_POST_XX_N_TIMES(count, error_name, err_subcode, message) |
#define | ERR_POST_XX_ONCE(error_name, err_subcode, message) ERR_POST_XX_N_TIMES(1, error_name, err_subcode, message) |
Error posting only once during program execution with given error code name and given error subcode. More... | |
#define | LOG_POST_XX_ONCE(error_name, err_subcode, message) LOG_POST_XX_N_TIMES(1, error_name, err_subcode, message) |
#define | DIAG_POST_LEVEL "DIAG_POST_LEVEL" |
Diagnostic post severity level. More... | |
#define | DIAG_TRACE "DIAG_TRACE" |
Diagnostic trace setting. More... | |
#define | DIAG_MESSAGE_FILE "MessageFile" |
Diagnostic message file. More... | |
Typedefs | |
typedef int | TDiagPostFlags |
Binary OR of "EDiagPostFlag". More... | |
typedef void(* | FAbortHandler) (void) |
Abort handler function type. More... | |
typedef void(* | FDiagHandler) (const SDiagMessage &mess) |
Diagnostic handler function type. More... | |
typedef void(* | FDiagCleanup) (void *data) |
Diagnostic cleanup function type. More... | |
Functions | |
const char * | g_DiagUnknownFunction (void) |
void | CheckErrSubcodeX (int) |
Additional dummy function for use in NCBI_CHECK_ERR_SUBCODE_X macro. More... | |
bool | IsSetDiagPostFlag (EDiagPostFlag flag, TDiagPostFlags flags=eDPF_Default) |
Check if a specified flag is set. More... | |
TDiagPostFlags | SetDiagPostAllFlags (TDiagPostFlags flags) |
Set global post flags to "flags". More... | |
void | SetDiagPostFlag (EDiagPostFlag flag) |
Set the specified flag (globally). More... | |
void | UnsetDiagPostFlag (EDiagPostFlag flag) |
Unset the specified flag (globally). More... | |
TDiagPostFlags | SetDiagTraceAllFlags (TDiagPostFlags flags) |
Versions of the above for extra trace flags. More... | |
void | SetDiagTraceFlag (EDiagPostFlag flag) |
void | UnsetDiagTraceFlag (EDiagPostFlag flag) |
void | SetDiagPostPrefix (const char *prefix) |
Specify a string to prefix all subsequent error postings with. More... | |
void | PushDiagPostPrefix (const char *prefix) |
Push a string to the list of message prefixes. More... | |
void | PopDiagPostPrefix (void) |
Pop a string from the list of message prefixes. More... | |
Uint8 | GetDiagRequestId (void) |
Get iteration number/request ID. More... | |
void | SetDiagRequestId (Uint8 id) |
Set iteration number/request ID. More... | |
Uint8 | GetFastCGIIteration (void) |
void | SetFastCGIIteration (Uint8 id) |
EDiagSev | SetDiagPostLevel (EDiagSev post_sev=eDiag_Error) |
Set the threshold severity for posting the messages. More... | |
EDiagSev | GetDiagPostLevel (void) |
Get current threshold severity for posting the messages. More... | |
int | CompareDiagPostLevel (EDiagSev sev1, EDiagSev sev2) |
Compare two severities. More... | |
bool | IsVisibleDiagPostLevel (EDiagSev sev) |
Check if the specified severity is higher or equal to the currently selected post level and will be printed by ERR_POST. More... | |
bool | DisableDiagPostLevelChange (bool disable_change=true) |
Disable change the diagnostic post level. More... | |
void | SetDiagFixedPostLevel (EDiagSev post_sev) |
Sets and locks the level, combining the previous two calls. More... | |
EDiagSev | SetDiagDieLevel (EDiagSev die_sev=eDiag_Fatal) |
Set the "die" (abort) level for the program. More... | |
EDiagSev | GetDiagDieLevel (void) |
Get the "die" (abort) level for the program. More... | |
bool | IgnoreDiagDieLevel (bool ignore) |
Ignore the die level settings. More... | |
void | SetAbortHandler (FAbortHandler func=0) |
Set/unset abort handler. More... | |
NCBI_XNCBI_EXPORT void | Abort (void) |
Smart abort function. More... | |
void | SetDiagTrace (EDiagTrace how, EDiagTrace dflt=eDT_Default) |
Set the diagnostic trace settings. More... | |
bool | GetDiagTrace (void) |
Check if traces are enabled. More... | |
CNcbiOstream & | operator<< (CNcbiOstream &os, const SDiagMessage &mess) |
Insert message in output stream. More... | |
CDiagContext & | GetDiagContext (void) |
Get diag context instance. More... | |
void | SetDiagHandler (CDiagHandler *handler, bool can_delete=true) |
Set the diagnostic handler using the specified diagnostic handler class. More... | |
CDiagHandler * | GetDiagHandler (bool take_ownership=false, bool *current_ownership=0) |
Get the currently set diagnostic handler class. More... | |
void | SetDiagHandler (FDiagHandler func, void *data, FDiagCleanup cleanup) |
Set the diagnostic handler using the specified diagnostic handler and cleanup functions. More... | |
bool | IsSetDiagHandler (void) |
Check if diagnostic handler is set. More... | |
void | DiagHandler_Reopen (void) |
Ask diagnostic handler to reopen log files if necessary. More... | |
void | SetDiagFilter (EDiagFilter what, const char *filter_str) |
Set diagnostic filter. More... | |
string | GetDiagFilter (EDiagFilter what) |
Get current diagnostic filter. More... | |
void | AppendDiagFilter (EDiagFilter what, const char *filter_str) |
Append diagnostic filter. More... | |
void | SetDoubleDiagHandler (void) |
Output diagnostics using both old and new style handlers. More... | |
void | SetDiagStream (CNcbiOstream *os, bool quick_flush=true, FDiagCleanup cleanup=0, void *cleanup_data=0, const string &stream_name="") |
Set diagnostic stream. More... | |
bool | IsDiagStream (const CNcbiOstream *os) |
CNcbiOstream * | GetDiagStream (void) |
Get current diagnostic stream (if it was set by SetDiagStream) or NULL. More... | |
void | SetSplitLogFile (bool value=true) |
Split log files flag. More... | |
bool | GetSplitLogFile (void) |
Get split log files flag. More... | |
bool | SetLogFile (const string &file_name, EDiagFileType file_type=eDiagFile_All, bool quick_flush=true) |
Set log files. More... | |
string | GetLogFile (EDiagFileType file_type) |
Get log file name for the given log type. More... | |
string | GetLogFile (void) |
Get log file name or diag handler name. More... | |
void | g_Diag_Use_RWLock (bool enable=true) |
Use RW-lock for synchronization rather than mutex. More... | |
void | SetDiagErrCodeInfo (CDiagErrCodeInfo *info, bool can_delete=true) |
Set handler for processing error codes. More... | |
bool | IsSetDiagErrCodeInfo () |
Indicates whether an error-code processing handler has been set. More... | |
CDiagErrCodeInfo * | GetDiagErrCodeInfo (bool take_ownership=false) |
Get handler for processing error codes. More... | |
Defines NCBI C++ diagnostic APIs, classes, and macros.
More elaborate documentation could be found in: http://ncbi.github.io/cxx-toolkit/pages/ch_log.html
Definition in file ncbidiag.hpp.