y2log.h

Go to the documentation of this file.
00001 /* y2log.h
00002  *
00003  * YaST2: Core system
00004  *
00005  * YaST2 logging implementation
00006  *
00007  * Authors: Mathias Kettner <kettner@suse.de>
00008  *          Michal Svec <msvec@suse.cz>
00009  *
00010  */
00011 
00012 #ifndef _y2log_ycp_h
00013 #define _y2log_ycp_h
00014 
00015 #include <y2util/y2log.h>
00016 #include "ExecutionEnvironment.h"
00017 
00018 /* YCP Errors */
00019 
00020 #define y2scanner(file,line,format,args...) \
00021     y2_logger(LOG_ERROR,"Scanner",file,line,"",format,##args)
00022 #define syn2error(file,line,format,args...) \
00023     y2_logger(LOG_ERROR,"Parser",file,line,"",format,##args)
00024 #define syn2warning(file,line,format,args...) \
00025     y2_logger(LOG_WARNING,"Parser",file,line,"",format,##args)
00026 #define sem2error(file,line,format,args...) \
00027     y2_logger(LOG_ERROR,"Runtime",file,line,"",format,##args)
00028 
00029 #define ycp2log(level,file,line,func,format,args...) \
00030     y2_logger(level,"YCP",file,line,func,format,##args)
00031 
00032 #define y2ycp(level,file,line,format,args...) \
00033     y2_logger(level,"Interpreter",file,line,"",format,##args)
00034 
00035 #define ycp2debug(file,line,format,args...) \
00036     y2ycp(LOG_DEBUG,file,line,format,##args)
00037 #define ycp2milestone(file,line,format,args...) \
00038     y2ycp(LOG_MILESTONE,file,line,format,##args)
00039 #define ycp2warning(file,line,format,args...) \
00040     y2ycp(LOG_WARNING,file,line,format,##args)
00041 #define ycp2error(format,args...)               \
00042     do {                                        \
00043         extern ExecutionEnvironment ee;         \
00044         y2ycp(LOG_ERROR, ee.filename().c_str(), ee.linenumber(), format, ##args);       \
00045     } while (0)
00046 #define ycp2error(format,args...)               \
00047     do {                                        \
00048         extern ExecutionEnvironment ee;         \
00049         y2ycp(LOG_ERROR, ee.filename().c_str(), ee.linenumber(), format, ##args);       \
00050     } while (0)
00051 #define ycp2security(file,line,format,args...) \
00052     y2ycp(LOG_SECURITY,file,line,format,##args)
00053 #define ycp2internal(file,line,format,args...) \
00054     y2ycp(LOG_INTERNAL,file,line,format,##args)
00055 
00056 // logging cleanup
00057 #define ycp_log(level,format,args...)           \
00058     do {                                        \
00059         extern ExecutionEnvironment ee;         \
00060         y2_logger(level, Y2LOG, ee.filename().c_str(), ee.linenumber(), "", format, ##args);    \
00061     } while (0)
00062 
00063 
00064 #define ycperror(format,args...)                \
00065     ycp_log(LOG_ERROR, format, ##args)
00066 
00067 #define ycpwarning(format,args...)              \
00068     ycp_log(LOG_WARNING, format, ##args)
00069 
00070 #define ycpdebug(format,args...)                \
00071     ycp_log(LOG_DEBUG, format, ##args)
00072 
00073 #define ycpinternal(format,args...)             \
00074     ycp_log(LOG_INTERNAL, format, ##args)
00075 
00076 #define ycpmilestone(format,args...)            \
00077     ycp_log(LOG_MILESTONE, format, ##args)
00078 
00079 // c++ interface for logging
00080 class Logger {
00081 public:
00082     virtual ~Logger() {}
00083     virtual void error(string error) = 0;
00084     virtual void warning(string warning) = 0;
00085 };
00086 
00087 #endif /* _y2log_ycp_h */

Generated on Fri Jun 16 18:07:45 2006 for yast2-core by  doxygen 1.4.6