嵌入式 linux编程中自定义LOG宏示例
来源:互联网 发布:.net编程语言 编辑:程序博客网 时间:2024/05/17 22:34
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <stdarg.h>
#ifdef _DEBUG_JOSEPH
#define _DEBUG_WIFI_KJ
#else
#endif
/*
author : kj
time : 2013-12-06 21:36
instruction:
get the num of the current seconds
*/
int get_current_time_to_jms(char *buf)
{
struct tm *tmnow;
struct timeval tv;
gettimeofday(&tv,NULL);
tmnow = localtime(&tv.tv_sec);
sprintf(buf,"%04d-%02d-%02d %02d:%02d:%02d",\
tmnow->tm_year+1900, tmnow->tm_mon+1, tmnow->tm_mday,tmnow->tm_hour,\
tmnow->tm_min, tmnow->tm_sec);
return tv.tv_sec;
}
int personal_print(const char *format, ...)
{
#ifdef _DEBUG_WIFI_KJ
char now_time[32];
char s[1024];
char content[1024];
bzero(content,1024);
bzero(now_time,32);
va_list arg;
va_start (arg, format);
vsprintf (s, format, arg);
va_end (arg);
get_current_time_to_jms(now_time);
sprintf(content,"%s %s",now_time,s);
printf("%s",content);
#else
return 0;
#endif
}
int main()
{
char buf[32]="kj";
personal_print("%s %d The content of buf is %s\n",__FUNCTION__,__LINE__,buf);
return 0;
}
Compile:
gcc -D_DEBUG_JOSEPH -o macro_printf macro_printf.c
- 嵌入式 linux编程中自定义LOG宏示例
- 嵌入式Linux下Gstreamer编程示例
- 嵌入式 Linux 中自定义 reboot / poweroff 行为
- 嵌入式linux中PCM音频编程实践
- Swift中自定义Log
- linux中多线程编程的简单示例
- linux log 日志编程
- 嵌入式Linux web配置示例
- 嵌入式linux多线程编程
- 嵌入式Linux Web 编程
- 嵌入式linux串口编程
- 嵌入式Linux网络编程
- 嵌入式Linux网络编程
- 嵌入式Linux网络编程
- 嵌入式Linux网络编程
- 嵌入式Linux--网络编程
- 嵌入式linux串口编程
- 嵌入式linux网络编程
- VS2012中CSting , std::string , char * 之间的转换
- 常用工具软件列表
- C语言可变参数函数
- Python Collection 小技巧
- 关于Dos命令的使用简介
- 嵌入式 linux编程中自定义LOG宏示例
- 危险代码:内存中的Java类和对象为何变得不安全—Part4
- 在线算法学习
- ZOJ-2554
- 关于Datasource与数据库连接池的区别。
- 黑马程序员------- 抽象类和接口-------
- XCode 同一Project创建多个target
- 剑指OFFER之队列
- 用Python和Pygame写游戏-从入门到精通(3)