log.h

来自「一个基于linux的TCP/IP协议栈的实现」· C头文件 代码 · 共 72 行

H
72
字号
/* log.h * linqianghe@163.com * 2006-09-01 */#ifndef INCLUDED_LOG_H#define INCLUDED_LOG_H#define __SHORTFILE__ \	({\		char *header = __FILE__;	\		char *ptr = header + strlen( header ) - 1; \		while( *ptr != '/' && ptr != header ) \			ptr --; \		if( *ptr == '/')\			ptr ++;\		ptr; \	})#ifdef __KERNEL__	#define PR_TRACE( fmt, args... )\		printk( KERN_ERR "%s[%d]:%s[TRACE]: " fmt, __SHORTFILE__, \			__LINE__, __FUNCTION__, ##args )	#define PR_TRACEC( fmt, args... )	#define PR_ERR( fmt, args... ) \		printk( KERN_ERR "%s[%d]:%s[ERR]: " fmt, __SHORTFILE__, \			__LINE__, __FUNCTION__, ##args )	#define PR_WARN( fmt, args... ) \		printk( KERN_WARNING "%s[%d]:%s[WARNING]: " fmt, __SHORTFILE__, \			__LINE__, __FUNCTION__, ##args )	#define PR_NOTICE( fmt, args... ) \		printk(KERN_NOTICE "%s[%d]:%s[NOTICE]: " fmt, __SHORTFILE__, \			__LINE__, __FUNCTION__, ##args )	#ifdef MYIPV4_DEEP_DEBUG		#define PR_DEEP_DEBUG( fmt, args... ) \			printk( KERN_NOTICE "%s[%d]:%s[DEBUG]: " fmt, __SHORTFILE__, \								__LINE__, __FUNCTION__, ##args )	#else			#define PR_DEEP_DEBUG( fmt, args... )	#endif	#ifdef MYIPV4_DEBUG		#define PR_DEBUG( fmt, args... ) \			printk( KERN_NOTICE "%s[%d]:%s[DEBUG]: " fmt,  __SHORTFILE__, \								__LINE__,  __FUNCTION__, ##args )	#else		#define PR_DEBUG( fmt, args... )	#endif#else	#include <string.h>	#define PR_ERR( fmt, args... ) \		fprintf( stderr, "%s[%d]:%s[ERR]: " fmt, __SHORTFILE__, \						__LINE__, __FUNCTION__, ##args )	#define PR_WARN( fmt, args... ) \		fprintf( stderr, "%s[%d]:%s[WARNING]: " fmt, __SHORTFILE__, \						__LINE__, __FUNCTION__, ##args )	#define PR_NOTICE( fmt, args... ) \		fprintf( stdout, "%s[%d]:%s[NOTICE]: " fmt, __SHORTFILE__, \						__LINE__, __FUNCTION__, ##args )	#ifdef APP_DEBUG			#define PR_DEBUG( fmt, args... ) \			fprintf( stdout, "%s[%d]:%s[DEBUG]: " fmt,  __SHORTFILE__, \							__LINE__,  __FUNCTION__, ##args )	#else		#define PR_DEBUG( fmt, args... )	#endif#endif#endif //INCLUDED_LOG_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?