Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
698d80a8
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
698d80a8
编写于
12月 22, 2008
作者:
D
Daniel Veillard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* src/logging.h src/logging.c: commited the more recent version
with function name and line number daniel
上级
9fcbbd92
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
75 addition
and
39 deletion
+75
-39
ChangeLog
ChangeLog
+5
-0
src/logging.c
src/logging.c
+30
-17
src/logging.h
src/logging.h
+40
-22
未找到文件。
ChangeLog
浏览文件 @
698d80a8
Mon Dec 22 11:43:04 CET 2008 Daniel Veillard <veillard@redhat.com>
* src/logging.h src/logging.c: commited the more recent version
with function name and line number
Mon Dec 22 11:33:07 CET 2008 Daniel Veillard <veillard@redhat.com>
Mon Dec 22 11:33:07 CET 2008 Daniel Veillard <veillard@redhat.com>
* src/logging.h src/logging.c: add the infrastructure and internal
* src/logging.h src/logging.c: add the infrastructure and internal
...
...
src/logging.c
浏览文件 @
698d80a8
...
@@ -469,6 +469,8 @@ cleanup:
...
@@ -469,6 +469,8 @@ cleanup:
* virLogMessage:
* virLogMessage:
* @category: where is that message coming from
* @category: where is that message coming from
* @priority: the priority level
* @priority: the priority level
* @funcname: the function emitting the (debug) message
* @linenr: line where the message was emitted
* @flags: extra flags, 1 if coming from the error handler
* @flags: extra flags, 1 if coming from the error handler
* @fmt: the string format
* @fmt: the string format
* @...: the arguments
* @...: the arguments
...
@@ -476,13 +478,13 @@ cleanup:
...
@@ -476,13 +478,13 @@ cleanup:
* Call the libvirt logger with some informations. Based on the configuration
* Call the libvirt logger with some informations. Based on the configuration
* the message may be stored, sent to output or just discarded
* the message may be stored, sent to output or just discarded
*/
*/
void
virLogMessage
(
const
char
*
category
,
int
priority
,
int
flags
,
void
virLogMessage
(
const
char
*
category
,
int
priority
,
const
char
*
funcname
,
const
char
*
fmt
,
...)
{
long
long
linenr
,
int
flags
,
const
char
*
fmt
,
...)
{
char
*
str
=
NULL
;
char
*
str
=
NULL
;
char
*
msg
;
char
*
msg
;
struct
timeval
cur_time
;
struct
timeval
cur_time
;
struct
tm
time_info
;
struct
tm
time_info
;
int
len
,
fprio
,
i
;
int
len
,
fprio
,
i
,
ret
;
if
(
!
virLogInitialized
)
if
(
!
virLogInitialized
)
virLogStartup
();
virLogStartup
();
...
@@ -509,15 +511,22 @@ void virLogMessage(const char *category, int priority, int flags,
...
@@ -509,15 +511,22 @@ void virLogMessage(const char *category, int priority, int flags,
gettimeofday
(
&
cur_time
,
NULL
);
gettimeofday
(
&
cur_time
,
NULL
);
localtime_r
(
&
cur_time
.
tv_sec
,
&
time_info
);
localtime_r
(
&
cur_time
.
tv_sec
,
&
time_info
);
if
(
asprintf
(
&
msg
,
"%02d:%02d:%02d.%03d: %s : %s
\n
"
,
if
((
funcname
!=
NULL
)
&&
(
priority
==
VIR_LOG_DEBUG
))
{
ret
=
asprintf
(
&
msg
,
"%02d:%02d:%02d.%03d: %s : %s:%lld : %s
\n
"
,
time_info
.
tm_hour
,
time_info
.
tm_min
,
time_info
.
tm_hour
,
time_info
.
tm_min
,
time_info
.
tm_sec
,
(
int
)
cur_time
.
tv_usec
/
1000
,
time_info
.
tm_sec
,
(
int
)
cur_time
.
tv_usec
/
1000
,
virLogPriorityString
(
priority
),
str
)
<
0
)
{
virLogPriorityString
(
priority
),
funcname
,
linenr
,
str
);
/* apparently we're running out of memory */
}
else
{
ret
=
asprintf
(
&
msg
,
"%02d:%02d:%02d.%03d: %s : %s
\n
"
,
time_info
.
tm_hour
,
time_info
.
tm_min
,
time_info
.
tm_sec
,
(
int
)
cur_time
.
tv_usec
/
1000
,
virLogPriorityString
(
priority
),
str
);
}
VIR_FREE
(
str
);
VIR_FREE
(
str
);
if
(
ret
<
0
)
{
/* apparently we're running out of memory */
return
;
return
;
}
}
VIR_FREE
(
str
);
/*
/*
* Log based on defaults, first store in the history buffer
* Log based on defaults, first store in the history buffer
...
@@ -532,8 +541,8 @@ void virLogMessage(const char *category, int priority, int flags,
...
@@ -532,8 +541,8 @@ void virLogMessage(const char *category, int priority, int flags,
virLogLock
();
virLogLock
();
for
(
i
=
0
;
i
<
virLogNbOutputs
;
i
++
)
{
for
(
i
=
0
;
i
<
virLogNbOutputs
;
i
++
)
{
if
(
priority
>=
virLogOutputs
[
i
].
priority
)
if
(
priority
>=
virLogOutputs
[
i
].
priority
)
virLogOutputs
[
i
].
f
(
virLogOutputs
[
i
].
data
,
category
,
priority
,
virLogOutputs
[
i
].
f
(
category
,
priority
,
funcname
,
linenr
,
msg
,
len
);
msg
,
len
,
virLogOutputs
[
i
].
data
);
}
}
if
((
virLogNbOutputs
==
0
)
&&
(
flags
!=
1
))
if
((
virLogNbOutputs
==
0
)
&&
(
flags
!=
1
))
safewrite
(
2
,
msg
,
len
);
safewrite
(
2
,
msg
,
len
);
...
@@ -542,9 +551,11 @@ void virLogMessage(const char *category, int priority, int flags,
...
@@ -542,9 +551,11 @@ void virLogMessage(const char *category, int priority, int flags,
VIR_FREE
(
msg
);
VIR_FREE
(
msg
);
}
}
static
int
virLogOutputToFd
(
void
*
data
,
const
char
*
category
ATTRIBUTE_UNUSED
,
static
int
virLogOutputToFd
(
const
char
*
category
ATTRIBUTE_UNUSED
,
int
priority
ATTRIBUTE_UNUSED
,
int
priority
ATTRIBUTE_UNUSED
,
const
char
*
str
,
int
len
)
{
const
char
*
funcname
ATTRIBUTE_UNUSED
,
long
long
linenr
ATTRIBUTE_UNUSED
,
const
char
*
str
,
int
len
,
void
*
data
)
{
int
fd
=
(
long
)
data
;
int
fd
=
(
long
)
data
;
int
ret
;
int
ret
;
...
@@ -582,10 +593,12 @@ static int virLogAddOutputToFile(int priority, const char *file) {
...
@@ -582,10 +593,12 @@ static int virLogAddOutputToFile(int priority, const char *file) {
}
}
#if HAVE_SYSLOG_H
#if HAVE_SYSLOG_H
static
int
virLogOutputToSyslog
(
void
*
data
ATTRIBUTE_UNUSED
,
static
int
virLogOutputToSyslog
(
const
char
*
category
ATTRIBUTE_UNUSED
,
const
char
*
category
ATTRIBUTE_UNUSED
,
int
priority
,
int
priority
,
const
char
*
str
,
const
char
*
funcname
ATTRIBUTE_UNUSED
,
int
len
ATTRIBUTE_UNUSED
)
{
long
long
linenr
ATTRIBUTE_UNUSED
,
const
char
*
str
,
int
len
ATTRIBUTE_UNUSED
,
void
*
data
ATTRIBUTE_UNUSED
)
{
int
prio
;
int
prio
;
switch
(
priority
)
{
switch
(
priority
)
{
...
...
src/logging.h
浏览文件 @
698d80a8
...
@@ -30,16 +30,22 @@
...
@@ -30,16 +30,22 @@
* defined at runtime of from the libvirt daemon configuration file
* defined at runtime of from the libvirt daemon configuration file
*/
*/
#ifdef ENABLE_DEBUG
#ifdef ENABLE_DEBUG
#define VIR_DEBUG(category, f
mt,...)
\
#define VIR_DEBUG(category, f
, l, fmt,...)
\
virLogMessage(category, VIR_LOG_DEBUG, 0, fmt, __VA_ARGS__)
virLogMessage(category, VIR_LOG_DEBUG,
f, l,
0, fmt, __VA_ARGS__)
#define VIR_INFO(category, f
mt,...)
\
#define VIR_INFO(category, f
, l, fmt,...)
\
virLogMessage(category, VIR_LOG_INFO, 0, fmt, __VA_ARGS__)
virLogMessage(category, VIR_LOG_INFO,
f, l,
0, fmt, __VA_ARGS__)
#define VIR_WARN(category, f
mt,...)
\
#define VIR_WARN(category, f
, l, fmt,...)
\
virLogMessage(category, VIR_LOG_WARN, 0, fmt, __VA_ARGS__)
virLogMessage(category, VIR_LOG_WARN,
f, l,
0, fmt, __VA_ARGS__)
#define VIR_ERROR(category, f
mt,...)
\
#define VIR_ERROR(category, f
, l, fmt,...)
\
virLogMessage(category, VIR_LOG_ERROR, 0, fmt, __VA_ARGS__)
virLogMessage(category, VIR_LOG_ERROR,
f, l,
0, fmt, __VA_ARGS__)
#else
#else
#define VIR_DEBUG(category, fmt,...) \
#define VIR_DEBUG(category, f, l, fmt,...) \
do { } while (0)
#define VIR_INFO(category, f, l, fmt,...) \
do { } while (0)
#define VIR_WARN(category, f, l, fmt,...) \
do { } while (0)
#define VIR_ERROR(category, f, l, fmt,...) \
do { } while (0)
do { } while (0)
#define VIR_INFO(category, fmt,...) \
#define VIR_INFO(category, fmt,...) \
do { } while (0)
do { } while (0)
...
@@ -49,14 +55,22 @@
...
@@ -49,14 +55,22 @@
do { } while (0)
do { } while (0)
#endif
/* !ENABLE_DEBUG */
#endif
/* !ENABLE_DEBUG */
#define DEBUG(fmt,...) VIR_DEBUG(__FILE__, fmt, __VA_ARGS__)
#define DEBUG(fmt,...) \
#define DEBUG0(msg) VIR_DEBUG(__FILE__, "%s", msg)
VIR_DEBUG("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
#define INFO(fmt,...) VIR_INFO(__FILE__, fmt, __VA_ARGS__)
#define DEBUG0(msg) \
#define INFO0(msg) VIR_INFO(__FILE__, "%s", msg)
VIR_DEBUG("file." __FILE__, __func__, __LINE__, "%s", msg)
#define WARN(fmt,...) VIR_WARN(__FILE__, fmt, __VA_ARGS__)
#define INFO(fmt,...) \
#define WARN0(msg) VIR_WARN(__FILE__, "%s", msg)
VIR_INFO("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
#define ERROR(fmt,...) VIR_ERROR(__FILE__, fmt, __VA_ARGS__)
#define INFO0(msg) \
#define ERROR0(msg) VIR_ERROR(__FILE__, "%s", msg)
VIR_INFO("file." __FILE__, __func__, __LINE__, "%s", msg)
#define WARN(fmt,...) \
VIR_WARN("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
#define WARN0(msg) \
VIR_WARN("file." __FILE__, __func__, __LINE__, "%s", msg)
#define ERROR(fmt,...) \
VIR_ERROR("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
#define ERROR0(msg) \
VIR_ERROR("file." __FILE__, __func__, __LINE__, "%s", msg)
/*
/*
...
@@ -71,18 +85,21 @@ typedef enum {
...
@@ -71,18 +85,21 @@ typedef enum {
/**
/**
* virLogOutputFunc:
* virLogOutputFunc:
* @data: extra output logging data
* @category: the category for the message
* @category: the category for the message
* @priority: the priority for the message
* @priority: the priority for the message
* @funcname: the function emitting the message
* @linenr: line where the message was emitted
* @msg: the message to log, preformatted and zero terminated
* @msg: the message to log, preformatted and zero terminated
* @len: the lenght of the message in bytes without the terminating zero
* @len: the lenght of the message in bytes without the terminating zero
* @data: extra output logging data
*
*
* Callback function used to output messages
* Callback function used to output messages
*
*
* Returns the number of bytes written or -1 in case of error
* Returns the number of bytes written or -1 in case of error
*/
*/
typedef
int
(
*
virLogOutputFunc
)
(
void
*
data
,
const
char
*
category
,
typedef
int
(
*
virLogOutputFunc
)
(
const
char
*
category
,
int
priority
,
int
priority
,
const
char
*
str
,
int
len
);
const
char
*
funcname
,
long
long
lineno
,
const
char
*
str
,
int
len
,
void
*
data
);
/**
/**
* virLogCloseFunc:
* virLogCloseFunc:
...
@@ -110,7 +127,8 @@ extern int virLogReset(void);
...
@@ -110,7 +127,8 @@ extern int virLogReset(void);
extern
void
virLogShutdown
(
void
);
extern
void
virLogShutdown
(
void
);
extern
int
virLogParseFilters
(
const
char
*
filters
);
extern
int
virLogParseFilters
(
const
char
*
filters
);
extern
int
virLogParseOutputs
(
const
char
*
output
);
extern
int
virLogParseOutputs
(
const
char
*
output
);
extern
void
virLogMessage
(
const
char
*
category
,
int
priority
,
int
flags
,
extern
void
virLogMessage
(
const
char
*
category
,
int
priority
,
const
char
*
fmt
,
...)
ATTRIBUTE_FORMAT
(
printf
,
4
,
5
);
const
char
*
funcname
,
long
long
linenr
,
int
flags
,
const
char
*
fmt
,
...)
ATTRIBUTE_FORMAT
(
printf
,
6
,
7
);
#endif
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录