Re: Windows MAGICK_CONFIGURE_PATH options

10bxjfhf <[email protected]> Sat, 7 Mar 2020 16:12:38 -0800
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============4996328782112680682==
Content-Type: multipart/alternative;
 boundary="------------036AD2D0D6593EF994E35514"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------036AD2D0D6593EF994E35514
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit

On 2020-03-07 10:33 a.m., Bob Friesenhahn wrote:
> On Sat, 7 Mar 2020, Bob Friesenhahn wrote:
>>
>>> Another approach: Is there any way to intercept the logging events, 
>>> similar to the error handlers?
>>
>> I am not aware of any.
>
> Now that I have looked I see that there is a SetLogMethod() function 
> declared in magick/log.h which may be used for this purpose.

Thank you finding this function.

In tracking down the details and figuring out how to use it, I came 
across a couple of issues my IDE flagged.

It appears that either has not cause any other issues, but I figured I 
might as well mention them so you can review them.

1) in log.c line 298 in my copy, it complains about dereferencing a NULL 
pointer

  /*
     Initialize logging semaphore
   */
   log_info->log_semaphore=AllocateSemaphoreInfo();


2) for the function

MagickExport  unsigned int LogMagickEventList(const ExceptionType type,

   const char *module,const char *function,const unsigned long line,

   const char *format,va_list operands)

it complains:
Warning    C6262    Function uses '16540' bytes of stack:  exceeds 
/analyze:stacksize '16384'.  Consider moving some data to heap. 
CORE_magick    D:\PKG\C++\MSVC2019\GM\GM-C031-D3ED\MAGICK\LOG.C 469

-----------------

Now for my testing results.

my function:

void MyLogFunc(const ExceptionType a_eType , const char* a_szBuf )
{
   wxLogMessage(_("++++ MyLogFunc - type: Bfr: %s"), a_szBuf );
}

-------------
my code
....
   InitializeMagick( static_cast<const char*>( wsExePath));
   SetErrorHandler( MyErrorHandler );
   SetLogMethod( MyLogFunc );
...

Initially I got no output.

After tracking through

MagickExport  unsigned int LogMagickEventList(const ExceptionType type,
   const char *module,const char *function,const unsigned long line,
   const char *format,va_list operands)

I found that I had to move the section testing for the MethodOutput to 
before the test for TXTFileOutput

because the flag was or'd in

Once I did so, I am getting log output; now I just have to work on 
understanding better what I get ;-)

Arnold


--------------036AD2D0D6593EF994E35514
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 2020-03-07 10:33 a.m., Bob
      Friesenhahn wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:[email protected]">On
      Sat, 7 Mar 2020, Bob Friesenhahn wrote: <br>
      <blockquote type="cite"> <br>
        <blockquote type="cite">Another approach: Is there any way to
          intercept the logging events, similar to the error handlers? <br>
        </blockquote>
        <br>
        I am not aware of any. <br>
      </blockquote>
      <br>
      Now that I have looked I see that there is a SetLogMethod()
      function declared in magick/log.h which may be used for this
      purpose. <br>
    </blockquote>
    <p>Thank you finding this function.</p>
    <p>In tracking down the details and figuring out how to use it, I
      came across a couple of issues my IDE flagged.</p>
    <p>It appears that either has not cause any other issues, but I
      figured I might as well mention them so you can review them.</p>
    <p>1) in log.c line 298 in my copy, it complains about dereferencing
      a NULL pointer</p>
    <pre> /*
    Initialize logging semaphore
  */
  log_info-&gt;log_semaphore=AllocateSemaphoreInfo();</pre>
    <p><br>
    </p>
    <p>2) for the function<br>
    </p>
    <pre>MagickExport  unsigned int LogMagickEventList(const ExceptionType type,</pre>
    <pre>  const char *module,const char *function,const unsigned long line,</pre>
    <pre>  const char *format,va_list operands)</pre>
    <p>it complains: <br>
      Warning    C6262    Function uses '16540' bytes of stack:  exceeds
      /analyze:stacksize '16384'.  Consider moving some data to heap.   
      CORE_magick    D:\PKG\C++\MSVC2019\GM\GM-C031-D3ED\MAGICK\LOG.C   
      469    <br>
    </p>
    <p>-----------------</p>
    <p>Now for my testing results. <br>
    </p>
    <p>my function:</p>
    <pre>void MyLogFunc(const ExceptionType a_eType , const char* a_szBuf )
{
  wxLogMessage(_("++++ MyLogFunc - type: Bfr: %s"), a_szBuf );
}

-------------
my code
....
  InitializeMagick( static_cast&lt;const char*&gt;( wsExePath));
  SetErrorHandler( MyErrorHandler );
  SetLogMethod( MyLogFunc );
... 
</pre>
    <p>Initially I got no output.</p>
    <p>After tracking through</p>
    <p>MagickExport  unsigned int LogMagickEventList(const ExceptionType
      type,<br>
        const char *module,const char *function,const unsigned long
      line,<br>
        const char *format,va_list operands)<br>
    </p>
    <p>I found that I had to move the section testing for the
      MethodOutput to before the test for TXTFileOutput</p>
    <p>because the flag was or'd in</p>
    <p>Once I did so, I am getting log output; now I just have to work
      on understanding better what I get ;-)<br>
    </p>
    <p>Arnold<br>
    </p>
  </body>
</html>

--------------036AD2D0D6593EF994E35514--


--===============4996328782112680682==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============4996328782112680682==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Graphicsmagick-apis mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-apis

--===============4996328782112680682==--