/*################################################################################### # # Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de # Embperl - Copyright (c) 2008-2015 Gerald Richter # Embperl - Copyright (c) 2015-2023 actevy.io # # You may distribute under the terms of either the GNU General Public # License or the Artistic License, as specified in the Perl README file. # For use with Apache httpd and mod_perl, see also Apache copyright. # # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # ###################################################################################*/ #include "ep.h" #include "epmacro.h" /*--------------------------------------------------------------------------- * DoLogError */ /*! * * \_en * Logs the occurence of an error to the embperl logfile and the httpd error log * * @param r the request object (maybe NULL) * @param a the application object (maybe NULL) * @param rc the error code * @param errdat1 addtional information * @param errdat2 addtional information * \endif * * \_de * logged das auftreten eines Fehler in das Embperl Logfile und den httpd * error log * * @param r das Requestobjekt (kann NULL sein) * @param a das Applikationobjekt (kann NULL sein) * @param rc Fehlercode * @param errdat1 Zusätzliche Informationen * @param errdat2 Zusätzliche Informationen * \endif * * ------------------------------------------------------------------------ */ static char * DoLogError (/*i/o*/ struct tReq * r, /*i/o*/ struct tApp * a, /*in*/ int rc, /*in*/ const char * errdat1, /*in*/ const char * errdat2) { const char * msg ; char * sText ; SV * pSV ; SV * pSVLine = NULL ; STRLEN l ; pid_t nPid ; #ifdef PERL_IMPLICIT_CONTEXT pTHX ; if (r) aTHX = r -> pPerlTHX ; else if (a) aTHX = a -> pPerlTHX ; else aTHX = PERL_GET_THX ; #endif if (r) { r -> errdat1 [sizeof (r -> errdat1) - 1] = '\0' ; r -> errdat2 [sizeof (r -> errdat2) - 1] = '\0' ; GetLineNo (r) ; errdat1 = r -> errdat1 ; errdat2 = r -> errdat2 ; if (rc != rcPerlWarn) r -> bError = 1 ; nPid = r -> pThread -> nPid ; a = r -> pApp ; } else if (a) { nPid = a -> pThread -> nPid ; } else nPid = getpid() ; if (!errdat1) errdat1 = "" ; if (!errdat2) errdat2 = "" ; switch (rc) { case ok: msg ="[%d]ERR: %d: %s ok%s%s" ; break ; case rcStackOverflow: msg ="[%d]ERR: %d: %s Stack Overflow%s%s" ; break ; case rcArgStackOverflow: msg ="[%d]ERR: %d: %s Argumnet Stack Overflow (%s)%s" ; break ; case rcStackUnderflow: msg ="[%d]ERR: %d: %s Stack Underflow%s%s" ; break ; case rcEndifWithoutIf: msg ="[%d]ERR: %d: %s endif without if%s%s" ; break ; case rcElseWithoutIf: msg ="[%d]ERR: %d: %s else without if%s%s" ; break ; case rcEndwhileWithoutWhile: msg ="[%d]ERR: %d: %s endwhile without while%s%s" ; break ; case rcEndtableWithoutTable: msg ="[%d]ERR: %d: %s blockend <%s> does not match blockstart <%s>" ; break ; case rcTablerowOutsideOfTable: msg ="[%d]ERR: %d: %s