c日志宏
仅供参考,不推荐
#ifdef _DEBUG
#define LOGDEBUG(format, ...)\
{\
FILE *fp = fopen("nccli.log", "ab+");if(fp!=NULL){\
time_t t = time(0);\
struct tm ttt = *localtime(&t);\
fprintf(fp, "[DEBUG] [%5d %4d-%02d-%02d %02d:%02d:%02d] [%s:%d] " format "",\
GetCurrentProcessId(), ttt.tm_year + 1900, ttt.tm_mon + 1, ttt.tm_mday, ttt.tm_hour,\
ttt.tm_min, ttt.tm_sec, __FUNCTION__ , __LINE__, ##__VA_ARGS__);\
fclose(fp);}\
}
#define LOGERROR(format, ...)\
{\
FILE *fp = fopen("nccli.log", "ab+");if(fp!=NULL){\
time_t t = time(0);\
struct tm ttt = *localtime(&t);\
fprintf(fp, "[ERROR] [%5d %4d-%02d-%02d %02d:%02d:%02d] [%s:%d] " format "",\
GetCurrentProcessId(), ttt.tm_year + 1900, ttt.tm_mon + 1, ttt.tm_mday, ttt.tm_hour,\
ttt.tm_min, ttt.tm_sec, __FUNCTION__ , __LINE__, ##__VA_ARGS__);\
fclose(fp);}\
}
#else
#define LOGDEBUG(format, ...)\
{\
time_t t = time(0);\
struct tm ttt = *localtime(&t);\
fprintf(stdout, "[DEBUG] [%5d %4d-%02d-%02d %02d:%02d:%02d] [%s:%d] " format "",\
GetCurrentProcessId(), ttt.tm_year + 1900, ttt.tm_mon + 1, ttt.tm_mday, ttt.tm_hour,\
ttt.tm_min, ttt.tm_sec, __FUNCTION__ , __LINE__, ##__VA_ARGS__);\
}
#define LOGERROR(format, ...)\
{\
time_t t = time(0);\
struct tm ttt = *localtime(&t);\
fprintf(stderr, "[ERROR] [%5d %4d-%02d-%02d %02d:%02d:%02d] [%s:%d] " format "",\
GetCurrentProcessId(), ttt.tm_year + 1900, ttt.tm_mon + 1, ttt.tm_mday, ttt.tm_hour,\
ttt.tm_min, ttt.tm_sec, __FUNCTION__ , __LINE__, ##__VA_ARGS__);\
}
#endif
c日志宏的更多相关文章
- 一只简单的网络爬虫(基于linux C/C++)————读取命令行参数及日志宏设计
linux上面的程序刚开始启动的时候一般会从命令行获取某些参数,比如以守护进程运行啊什么的,典型的例子就是linux下的man,如下图所示 实现该功能可以使用getopt函数实现,该函数在头文件uni ...
- Qt 日志宏
随便写了一个日志帮助的宏,既可以如同qDebug()一般在调试时输出信息,也可以在输出文本文件 #ifndef LOG_H #define LOG_H #include <QDir> #i ...
- iPhone开发技巧之日志保存教程
http://mobile.51cto.com/iphone-283337.htm Objective-C开发程序的时候,有专门的日志操作类NSLog,它将指定的输出到标准的错误输出上(stderr) ...
- 使用Line Pos Info 和 Modern C++ 改进打印日志记录
使用Line Pos Info 和 Modern C++ 改进打印日志记录 使用跟踪值:不管自己是多么的精通,可能仍然使用调试的主要方法之一 printf , TRaCE, outputDebugSt ...
- iOS - 常用宏定义和PCH文件知识点整理
(一)PCH文件操作步骤演示: 第一步:图文所示: 第二步:图文所示: (二)常用宏定义整理: (1)常用Log日志宏(输出日志详细可定位某个类.某个函数.某一行) //=============== ...
- C++ 日志库 boost::log 以及 glog 的对比
日志能方便地诊断程序原因.统计程序运行数据,是大型软件系统必不可少的组件之一.本文将从设计上和功能上对比 C++ 语言常见的两款日志库: boost::log 和 google-glog . 设计 b ...
- iOS-NSLog发布时取消打印日志
1 选择工程的Target -> Build Settings -> Preprocessor Macros. 如图,默认 Debug项,是“DEBUG=1”. 2 在程序中设置全局宏定义 ...
- LTE Manual ——Logging(翻译)
LTE Manual ——Logging(翻译) (本文为个人学习笔记,如有不当的地方,欢迎指正!) 9 Logging ns-3 日志功能可以用于监测或调试仿真程序的进展.日志输出可以通过 ma ...
- 对云风 cstring 第二次解析
前言 从明天起 关心粮食和蔬菜 我有一所房子 面朝大海 春暖花开 本文前提条件 1.了解 posix 线程 2.了解 原子操作 3.具备简单C基础,或者 你也敲一遍. 如果上面不太清楚,你可以翻看我以 ...
随机推荐
- nginx源码安装教程(CentOS)
1.说明 官方源码安装说明:http://nginx.org/en/docs/configure.html 源码包下载地址:http://nginx.org/en/download.html 版本说明 ...
- java集合类,详解
集合详解 1.1HashSet HashSet是Set接口的一个子类,主要的特点是:里面不能存放重复元素,而且采用散列的存储方法,所以没有顺序.这里所说的没有顺序是指:元素插入的顺序与输出的顺序不一致 ...
- Struts初步入门(四)
1.默认Action-深入Struts struts.xml 文件: <struts> <package name="default" namespace=&qu ...
- laravel中db获取某个数据的具体字段值:
$helpfriend = DB::connection('luckyrecord')->table($luckyrecord)->where('id', $luckyrecordid)- ...
- python-第一类对象,闭包,迭代器
# def fn(): # print("我叫fn") # fn() # print(fn) # <function fn at 0x0000000001D12E18> ...
- oo作业总结(一)
概述 经历了三次oo作业的洗礼,让我对java语言的强大以及面向对象编程有了初步的理解(当然,我是小白).本文接下来就将对自己这三次作业的代码进行分析以及分享自己的心路历程. 基础知识点考核 针对前三 ...
- python,判断操作系统是windows,linux
import sys,platform print(sys.platform) print(platform.system()) sys.platform: 获取当前系统平台. platform.sy ...
- Java:<获取>、<删除>指定文件夹及里面所有文件
工具类代码如下: 一.获取 public Class Test{ //定义全局变量,存放所有文件夹下的文档 List<String> fileList ; public List<S ...
- java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result异常的解决方法
今天在写一个JAVA程序的时候出现了异常:java.lang.ArithmeticException: Non-terminating decimal expansion; no exact repr ...
- Chrome浏览器录屏扩展插件
Chrome浏览器录屏扩展插件,可以录制网页操作或者桌面操作.生成MP4 Loom https://chrome.google.com/webstore/detail/loom-video-recor ...