17 #define THIS_FILE "ftaerr.cpp"
19 #define MESSAGE_DIR "/am/ncbiapdata/errmsg"
118 const char*
months[] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec" };
120 thread_local unique_ptr<FtaMsgPost>
bmp;
126 if (strsevcode.empty())
137 if (
auto it = sStringToInt.
find(strsevcode);
138 it != sStringToInt.
end()) {
147 const char* module,
int code,
int subcode,
string& strcode,
string& strsubcode,
ErrSev& sevcode)
163 for (got_mod =
false, bmmfp =
bmp->bmmf; bmmfp; bmmfp = bmmfp->
next) {
164 if (bmmfp->
modname != module) {
169 for (bmmtp = bmmfp->
bmmt; bmmtp; bmmtp = bmmtp->
next) {
174 for (bmctxp = bmmtp->
bmctx; bmctxp; bmctxp = bmctxp->
next) {
192 fd = fopen(
buf.c_str(),
"r");
195 fd = fopen(
buf.c_str(),
"r");
210 while (fgets(s, 2047, fd)) {
211 if (s[0] !=
'$' || (s[1] !=
'^' && s[1] !=
'$'))
218 for (p = s + 2; *p ==
' ' || *p ==
'\t'; p++) {}
219 for (q = p; *p && *p !=
','; p++) {}
226 for (*p++ =
','; *p ==
' ' || *p ==
'\t'; p++) {}
227 for (q = p; *p >=
'0' && *p <=
'9'; p++) {}
242 if (s[1] ==
'^' && ch ==
',') {
243 for (p++; *p ==
' ' || *p ==
'\t'; p++) {}
245 *p && *p !=
' ' && *p !=
'\t' && *p !=
'\n' && *p !=
',';
250 if (!
strcmp(q,
"SEV_INFO") || !
strcmp(q,
"SEV_WARNING") ||
251 !
strcmp(q,
"SEV_ERROR") || !
strcmp(q,
"SEV_REJECT") ||
252 !
strcmp(q,
"SEV_FATAL")) {
267 if (val2 ==
code && strcode.empty())
273 if (! bmmfp->
bmmt || ! bmmtp) {
280 bmmtp->
bmctx = bmctxp;
286 if (val2 == subcode && strsubcode.empty() && ! strcode.empty()) {
307 bmp->hook_only =
false;
323 if (! name || *name ==
'\0')
327 bmp->prefix_accession = name;
330 bmp->prefix_locus = name;
334 strcpy(
tmp,
"FEAT=");
335 strncat(
tmp, name, 20);
341 bmp->prefix_feature =
tmp;
349 bmp->prefix_accession.clear();
352 bmp->prefix_locus.clear();
355 bmp->prefix_feature.clear();
366 if (! logfile || ! *logfile)
372 if (
bmp->logfile.empty()) {
373 bmp->logfile = logfile;
376 if (!
bmp->lfd && !
bmp->logfile.empty()) {
378 tm = localtime(&now);
379 i = tm->tm_hour % 12;
383 bmp->lfd = fopen(
bmp->logfile.c_str(),
"a");
385 "\n========================[ %s %d, %d %2d:%02d %s ]========================\n",
391 (tm->tm_hour >= 12) ?
"PM" :
"AM");
404 bmp->show_msg_codes =
true;
406 bmp->show_log_codes =
true;
408 bmp->show_msg_codeline =
true;
410 bmp->show_log_codeline =
true;
416 if (!
str ||
str[0] ==
'\0')
422 fprintf(
bmp->lfd,
"%s",
str);
467 switch (c_severity) {
488 return (cxx_severity);
495 char fpiBuffer[1024];
506 int fpiIntcode = lev1;
507 int fpiIntsubcode = lev2;
510 string fpiStrsubcode;
520 if (fpiModule && *fpiModule)
521 FtaErrGetMsgCodes(fpiModule, fpiIntcode, fpiIntsubcode, fpiStrcode, fpiStrsubcode, fpiSevcode);
528 if (
bmp->appname.empty())
531 stringstream textStream;
532 if (! fpiStrcode.empty()) {
533 textStream <<
"[" << fpiStrcode.c_str();
534 if (! fpiStrsubcode.empty()) {
535 textStream <<
"." << fpiStrsubcode.c_str();
540 if (
bmp->show_log_codeline) {
541 textStream <<
"{" << fpiFname <<
", line " << fpiLine;
543 if (!
bmp->prefix_locus.empty()) {
544 textStream <<
bmp->prefix_locus <<
": ";
546 if (!
bmp->prefix_accession.empty()) {
547 textStream <<
bmp->prefix_accession <<
": ";
549 if (!
bmp->prefix_feature.empty()) {
550 textStream <<
bmp->prefix_feature <<
" ";
564 .
Report(fpiModule ? fpiModule :
"",
565 sSeverityMap.at(fpiSevcode),
585 char fpiBuffer[1024];
606 if (
str.size() > 1024)
607 str =
str.substr(0, 1024);
static CFlatFileMessageReporter & GetInstance()
void Report(const string &module, EDiagSev severity, int code, int subcode, const string &text, int lineNum=-1)
const_iterator end() const
const_iterator find(const key_type &key) const
static ErrSev FtaStrSevToIntSev(const string &strsevcode)
bool ErrSetLog(const char *logfile)
string ErrFormat(const char *fmt,...)
ErrSev ErrSetLogLevel(ErrSev sev)
void FtaDeletePrefix(int prefix)
void Nlm_ErrSetContext(const char *module, const char *fname, int line)
thread_local unique_ptr< FtaMsgPost > bmp
void Nlm_ErrPostStr(ErrSev sev, int lev1, int lev2, string_view str)
void ErrSetOptFlags(int flags)
static void s_ReportError(ErrSev sev, int lev1, int lev2, string_view msg)
ErrSev ErrSetMessageLevel(ErrSev sev)
EDiagSev ErrCToCxxSeverity(int c_severity)
void ErrLogPrintStr(const char *str)
static void FtaErrGetMsgCodes(const char *module, int code, int subcode, string &strcode, string &strsubcode, ErrSev &sevcode)
void Nlm_ErrPostEx(ErrSev sev, int lev1, int lev2, const char *fmt,...)
void FtaInstallPrefix(int prefix, const char *name, const char *location)
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
static const char * str(char *buf, int n)
static const char location[]
static string GetAppName(EAppNameType name_type=eBaseName, int argc=0, const char *const *argv=NULL)
EDiagSev
Severity level for the posted diagnostics.
@ eDiag_Trace
Trace message.
@ eDiag_Info
Informational message.
@ eDiag_Error
Error message.
@ eDiag_Warning
Warning message.
@ eDiag_Fatal
Fatal error – guarantees exit(or abort)
@ eDiag_Critical
Critical error message.
static char GetPathSeparator(void)
Get path separator symbol specific for the current platform.
static string GetCwd(void)
Get the current working directory.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
int strcmp(const char *str1, const char *str2)
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)