logmsg.c

来自「Samsung公司S3C6400芯片的BSP源码包」· C语言 代码 · 共 61 行

C
61
字号
/*
 * Project Name MFC DRIVER 
 * Copyright  2007 Samsung Electronics Co, Ltd. All Rights Reserved. 
 *
 * This software is the confidential and proprietary information
 * of Samsung Electronics  ("Confidential Information").   
 * you shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Samsung Electronics 
 *
 * This source file is for printing the driver's log messages.
 *
 * @name MFC DRIVER MODULE Module (log_msg.c)
 * @author Jiun, Yu(jiun.yu@samsung.com)
 * @date 03-28-07
 */

#include <stdio.h>
#include <stdarg.h>

#if defined(LINUX)
#include <linux/kernel.h>
#include <asm/param.h>
#include <linux/delay.h>
#endif

#include "LogMsg.h"

static const LOG_LEVEL log_level = LOG_WARNING;

static const char *modulename = "MFC_DRV";

static const char *level_str[] = {"TRACE", "WARNING", "ERROR"};

void LOG_MSG(LOG_LEVEL level, const char *func_name, const char *msg, ...)
{
	char buf[256];
	va_list argptr;

	if (level < log_level)
		return;

	sprintf(buf, "[%s: %s] %s: ", modulename, level_str[level], func_name);

	va_start(argptr, msg);
	vsprintf(buf + strlen(buf), msg, argptr);
#if defined(_WIN32_WCE)
	printf(buf);
#elif defined(LINUX)
	printk(buf);
#endif
	va_end(argptr);
}

#ifndef _WIN32_WCE
void Sleep(unsigned int ms)
{
	udelay(ms);
}
#endif

⌨️ 快捷键说明

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