File:  [Qemu by Fabrice Bellard] / qemu / qemu-log.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:50:45 2018 UTC (3 years, 3 months ago) by root
Branches: qemu, MAIN
CVS tags: qemu1101, qemu1001, qemu1000, qemu0151, qemu0150, qemu0141, qemu0140, qemu0130, qemu0125, qemu0124, qemu0123, qemu0122, qemu0121, qemu0120, qemu0111, qemu0110, qemu0105, qemu0104, qemu0103, qemu0102, qemu0101, qemu0100, HEAD
qemu 0.10.0

    1: #ifndef QEMU_LOG_H
    2: #define QEMU_LOG_H
    3: 
    4: /* The deprecated global variables: */
    5: extern FILE *logfile;
    6: extern int loglevel;
    7: 
    8: 
    9: /* 
   10:  * The new API:
   11:  *
   12:  */
   13: 
   14: /* Log settings checking macros: */
   15: 
   16: /* Returns true if qemu_log() will really write somewhere
   17:  */
   18: #define qemu_log_enabled() (logfile != NULL)
   19: 
   20: /* Returns true if a bit is set in the current loglevel mask
   21:  */
   22: #define qemu_loglevel_mask(b) ((loglevel & (b)) != 0)
   23: 
   24: 
   25: /* Logging functions: */
   26: 
   27: /* main logging function
   28:  */
   29: #define qemu_log(...) do {                 \
   30:         if (logfile)                       \
   31:             fprintf(logfile, ## __VA_ARGS__); \
   32:     } while (0)
   33: 
   34: /* vfprintf-like logging function
   35:  */
   36: #define qemu_log_vprintf(fmt, va) do {     \
   37:         if (logfile)                       \
   38:             vfprintf(logfile, fmt, va);    \
   39:     } while (0)
   40: 
   41: /* log only if a bit is set on the current loglevel mask
   42:  */
   43: #define qemu_log_mask(b, ...) do {         \
   44:         if (loglevel & (b))                \
   45:             fprintf(logfile, ## __VA_ARGS__); \
   46:     } while (0)
   47: 
   48: 
   49: 
   50: 
   51: /* Special cases: */
   52: 
   53: /* cpu_dump_state() logging functions: */
   54: #define log_cpu_state(env, f) cpu_dump_state((env), logfile, fprintf, (f));
   55: #define log_cpu_state_mask(b, env, f) do {           \
   56:       if (loglevel & (b)) log_cpu_state((env), (f)); \
   57:   } while (0)
   58: 
   59: /* disas() and target_disas() to logfile: */
   60: #define log_target_disas(start, len, flags) \
   61:         target_disas(logfile, (start), (len), (flags))
   62: #define log_disas(start, len) \
   63:         disas(logfile, (start), (len))
   64: 
   65: /* page_dump() output to the log file: */
   66: #define log_page_dump() page_dump(logfile)
   67: 
   68: 
   69: 
   70: /* Maintenance: */
   71: 
   72: /* fflush() the log file */
   73: #define qemu_log_flush() fflush(logfile)
   74: 
   75: /* Close the log file */
   76: #define qemu_log_close() do { \
   77:         fclose(logfile);      \
   78:         logfile = NULL;       \
   79:     } while (0)
   80: 
   81: /* Set up a new log file */
   82: #define qemu_log_set_file(f) do { \
   83:         logfile = (f);            \
   84:     } while (0)
   85: 
   86: /* Set up a new log file, only if none is set */
   87: #define qemu_log_try_set_file(f) do { \
   88:         if (!logfile)                 \
   89:             logfile = (f);            \
   90:     } while (0)
   91: 
   92: 
   93: #endif

unix.superglobalmegacorp.com