Note that there are some explanatory texts on larger screens.

plurals
  1. POPantheios not logging into one file with MFC app comprise (one exe + two DLLs)
    primarykey
    data
    text
    <p>I have got an MFC app comprised of one exe and two DLLs. The exe calls functions from those two DLLs. Now I am trying to add some logging by using the Pantheios logging lib.</p> <p>What I want to achieve:<br> The exe and the two DLLs are all logging to the same log file in hard drive.</p> <p>Here is what I have done:<br></p> <p>1) Using implicit linking in main exe program:</p> <hr> <pre><code>#include "stdafx.h" #include &lt;pantheios/implicit_link/core.h&gt; #include &lt;pantheios/implicit_link/fe.simple.h&gt; #include &lt;pantheios/implicit_link/be.file.h&gt; #define USER_SPECIFIED_LEVEL #ifndef USER_SPECIFIED_LEVEL #include &lt;pantheios/implicit_link/fe.simple.h&gt; #endif #ifdef USER_SPECIFIED_LEVEL PANTHEIOS_CALL(int) pantheios_fe_init(void* reserved,void** ptoken) { *ptoken = NULL; return 0; } PANTHEIOS_CALL(void) pantheios_fe_uninit(void* token) {} PANTHEIOS_CALL(PAN_CHAR_T const*) pantheios_fe_getProcessIdentity (void * token) { return PANTHEIOS_LITERAL_STRING(MY_PROGRAM_ID); } PANTHEIOS_CALL(int) pantheios_fe_isSeverityLogged(void* token , int severity , int backEndId) { //SEV_CRITICAL=2 &lt; SEV_ERROR=3 &lt; SEV_WARNING=4 &lt; SEV_INFORMATIONAL=6 if(severity &lt;= pantheios::SEV_INFORMATIONAL) return 1;//allow output for anything above information lvl return 0; } #endif </code></pre> <hr> <p>In the main exe program where I need to add logging I use (after looked this <a href="https://stackoverflow.com/questions/10219300/connect-pantheios-logging-in-a-dll-to-the-main-applications-logging">link</a> in SO talking about <code>PANTHEIOS_BE_FILE_F_SHARE_ON_WINDOWS</code>):</p> <pre><code>pantheios_be_file_setFilePath(PSTR("C:\\TestLog.log"),**PANTHEIOS_BE_FILE_F_SHARE_ON_WINDOWS**, 0, PANTHEIOS_BEID_ALL); pantheios::log_NOTICE(PSTR("process id: ["), pantheios::processId, PSTR("]")); pantheios::log_NOTICE(PSTR("thread id: ["), pantheios::threadId, PSTR("]")); pantheios::log_INFORMATIONAL(PSTR("testing log messagse")); </code></pre> <p>This works fine, and I can get logging in c:\TestLog.log file as expected. However, I cannot get logging at all in those two DLLs, it simply gives erros for each logging call:</p> <pre><code> pantheios::log_INFORMATIONAL(PSTR("testing message")); </code></pre> <p>saying the token is emtpy, so I Googled and found a solution:</p> <p>2) I need to call:</p> <pre><code>pantheios::init(); </code></pre> <p>for each DLL initialization inside their <code>DllMain</code> function. This way, there is no more "empty token" error when I try to log in the DLL, but still there's nothing logged by the DLLs in the log file (again, the main exe program is fine). </p> <p>3) I tweaked stuff a bit and I have to change the logging file names in the DLL loggings so they all log to different files:</p> <p>DLL #1:</p> <pre><code>pantheios_be_file_setFilePath(PSTR("C:\\TestLogDll1.log"),PANTHEIOS_BE_FILE_F_SHARE_ON_WINDOWS, 0, PANTHEIOS_BEID_ALL); </code></pre> <p>DLL #2:</p> <pre><code>pantheios_be_file_setFilePath(PSTR("C:\\TestLogDll2.log"),PANTHEIOS_BE_FILE_F_SHARE_ON_WINDOWS, 0, PANTHEIOS_BEID_ALL); </code></pre> <p>This way I have 3 logging files all working fine:</p> <ul> <li>TestLog.log for the main program</li> <li>TestLogDll1.log for DLL #1</li> <li>TestLogDll2.log for DLL #2</li> </ul> <p>But still I just cannot get both DLLs logging to the same file as the main exe does (TestLog.log).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload