日志输出 定义
来源:互联网 发布:防范sql注入的常用方法 编辑:程序博客网 时间:2024/06/12 22:34
3 down vote accepted
/* * There are three levels of logging: debug, info and error, and each can be enabled independently * via the ENLOGGING_LEVEL_DEBUG, ENLOGGING_LEVEL_INFO, and ENLOGGING_LEVEL_ERROR switches below, respectively. * In addition, ALL logging can be enabled or disabled via the ENLOGGING_ENABLED switch below. * * To perform logging, use any of the following function calls in your code: * * ENDebug(fmt, …) – will print if ENLOGGING_LEVEL_DEBUG is set on. * ENInfo(fmt, …) – will print if ENLOGGING_LEVEL_INFO is set on. * ENHeading(fmt, …) – will print if ENLOGGING_LEVEL_INFO is set on. * ENError(fmt, …) – will print if ENLOGGING_LEVEL_ERROR is set on. * * Each logging entry can optionally automatically include class, method and line information by * enabling the ENLOGGING_INCLUDE_CODE_LOCATION switch. * * Logging functions are implemented here via macros, so disabling logging, either entirely, * or at a specific level, removes the corresponding log invocations from the compiled code, * thus completely eliminating both the memory and CPU overhead that the logging calls would add. */#define ENLOGGING_ENABLED 1// Set any or all of these switches to enable or disable logging at specific levels.#define ENLOGGING_LEVEL_DEBUG 1#define ENLOGGING_LEVEL_INFO 1#define ENLOGGING_LEVEL_ERROR 1// Set this switch to set whether or not to include class, method and line information in the log entries.#define ENLOGGING_INCLUDE_CODE_LOCATION 0////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Implementation////////////////////////////////////////////////////////////////////////////////////////////////////////////////////#if !(defined(ENLOGGING_ENABLED) && ENLOGGING_ENABLED)#undef ENLOGGING_LEVEL_DEBUG#undef ENLOGGING_LEVEL_INFO#undef ENLOGGING_LEVEL_ERROR#endif// Logging format#define ENLOG_FORMAT_NO_LOCATION(fmt, lvl, ...) NSLog((@"[%@] " fmt), lvl, ##__VA_ARGS__)#define ENLOG_FORMAT_WITH_LOCATION(fmt, lvl, ...) NSLog((@"%s [Line %d] [%@] " fmt), __PRETTY_FUNCTION__, __LINE__, lvl, ##__VA_ARGS__)#if defined(ENLOGGING_INCLUDE_CODE_LOCATION) && ENLOGGING_INCLUDE_CODE_LOCATION#define ENLOG_FORMAT(fmt, lvl, ...) ENLOG_FORMAT_WITH_LOCATION(fmt, lvl, ##__VA_ARGS__)#else#define ENLOG_FORMAT(fmt, lvl, ...) ENLOG_FORMAT_NO_LOCATION(fmt, lvl, ##__VA_ARGS__)#endif// Debug level logging#if defined(ENLOGGING_LEVEL_DEBUG) && ENLOGGING_LEVEL_DEBUG#define ENDebug(fmt, ...) ENLOG_FORMAT(fmt, @"debug", ##__VA_ARGS__)#else#define ENDebug(...)#endif// Info level logging#if defined(ENLOGGING_LEVEL_INFO) && ENLOGGING_LEVEL_INFO#define ENInfo(fmt, ...) ENLOG_FORMAT(fmt, @"info", ##__VA_ARGS__)#define ENHeading(fmt, ...) ENLOG_FORMAT(@"#################### " fmt " ####################", @"HD", ##__VA_ARGS__)#else#define ENInfo(...)#define ENHeading(...)#endif// Error level logging#if defined(ENLOGGING_LEVEL_ERROR) && ENLOGGING_LEVEL_ERROR#define ENError(fmt, ...) ENLOG_FORMAT(fmt, @"***ERROR***", ##__VA_ARGS__)#else#define ENError(...)#endif#if defined(ENLOGGING_LEVEL_ERROR) && ENLOGGING_LEVEL_ERROR#define ENResult(result, error) if (result == NO) ENError("%@", error)#else#define ENResult(...)#endifhttp://stackoverflow.com/questions/7294215/what-logging-solutions-to-use-while-log-debugging-objective-c-code/7294231#7294231
- 日志输出 定义
- 宏定义 日志输出
- 宏定义日志输出
- 宏定义实现printf日志输出
- 日志输出
- 日志输出
- 在linux系统中将自己程序的日志输出到自己定义的文件
- spring 基于aop 实现日志输出 定义在controller层无效
- 自己定义日志类
- 宏定义日志打印
- 日志宏定义
- Python日志定义
- Apache - 日志格式定义
- 日志的定义
- 重新定义日志成员
- C++ 日志宏定义
- 宏定义输出
- [ecshop 调试 ]ecshop中的 debug_mode 是在哪里定义的 查看sql日志 输出错误 显示debug
- 静态链接库LIB和动态链接库DLL的区别 创建和示例
- android开发 列表显示(ListView)
- 取文件修改内容,然后上传至另一个ftp
- Linux TCP/IP协议栈之Socket的实现分析
- [Android] 带有输入框(EditText)的提示框(AlertDialog)
- 日志输出 定义
- ORA-12516 解决方法
- PHP 页面编码声明方法详解(header或meta)
- 数据库原理(二)
- oracle日志操作模式(归档模式和非归档模式)
- dll编程
- javaweb项目中对于资源文件的读取
- 程序员,请昂起你高贵的头!
- linux下进程权限分析