Differences between revisions 8 and 9
Revision 8 as of 2007-08-21 21:29:27
Size: 1388
Editor: gtang
Comment:
Revision 9 as of 2008-11-26 04:42:29
Size: 1392
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
 * ~+EMAN2 use [http://blake.bcm.edu/eman2/doxygen_html/classEMAN_1_1Log.html Log class] to handle logging. Please refer to "[http://blake.bcm.edu/eman2/doxygen_html/log_8h-source.html log.h]".+~  * ~+EMAN2 use [[http://blake.bcm.edu/eman2/doxygen_html/classEMAN_1_1Log.html|Log class]] to handle logging. Please refer to "[[http://blake.bcm.edu/eman2/doxygen_html/log_8h-source.html|log.h]]".+~

How to use Log class in EMAN2 to print out error/warning/debugging information?

  • EMAN2 use Log class to handle logging. Please refer to "log.h".

  • The advantage to use Log class:

    • It defines a generic way to do logging. The logging may go to either standard out, a file, or a pipe.
    • It may give you best performance. Log functions are defined as macros. With an option to define all macros to be void, we may make the program completely silient and remove all the IO overhead.
    • It allows different level of verbosity from 0-4, with 0 means completely silient, 4 means very verbose.
  • How to use Log:
    • in your main() file, set log level: Log::logger()->set_log_level(WARNING_LOG), this will determine how much information you want it to be logged;

    • log message in different levels: (log functions use the same argument format like printf()):

     LOGERR("out of memory");
     LOGWARN("invalid image size");
     LOGDEBUG("image mean density = %f\n", mean);
     LOGVAR("image size = (%d, %d, %d)\n", nx, ny, nz);
  • To log function enter point, use ENTERFUNC; To log function exit point, use EXITFUNC.

    void foo()
    {
        ENTERFUNC;
        ......
        EXITFUNC;
    }

eman2Log (last edited 2022-02-18 00:34:48 by TunayDurmaz)