Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
9c104c68
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9c104c68
编写于
2月 09, 2011
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
introduced a new logging function for big messages
上级
a8cc969c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
8 deletion
+20
-8
src/redis.c
src/redis.c
+20
-8
未找到文件。
src/redis.c
浏览文件 @
9c104c68
...
...
@@ -192,24 +192,20 @@ struct redisCommand redisCommandTable[] = {
/*============================ Utility functions ============================ */
void
redisLog
(
int
level
,
const
char
*
fmt
,
...)
{
/* Low level logging. To use only for very big messages, otherwise
* redisLog() is to prefer. */
void
redisLogRaw
(
int
level
,
const
char
*
msg
)
{
const
int
syslogLevelMap
[]
=
{
LOG_DEBUG
,
LOG_INFO
,
LOG_NOTICE
,
LOG_WARNING
};
const
char
*
c
=
".-*#"
;
time_t
now
=
time
(
NULL
);
va_list
ap
;
FILE
*
fp
;
char
buf
[
64
];
char
msg
[
REDIS_MAX_LOGMSG_LEN
];
if
(
level
<
server
.
verbosity
)
return
;
fp
=
(
server
.
logfile
==
NULL
)
?
stdout
:
fopen
(
server
.
logfile
,
"a"
);
if
(
!
fp
)
return
;
va_start
(
ap
,
fmt
);
vsnprintf
(
msg
,
sizeof
(
msg
),
fmt
,
ap
);
va_end
(
ap
);
strftime
(
buf
,
sizeof
(
buf
),
"%d %b %H:%M:%S"
,
localtime
(
&
now
));
fprintf
(
fp
,
"[%d] %s %c %s
\n
"
,(
int
)
getpid
(),
buf
,
c
[
level
],
msg
);
fflush
(
fp
);
...
...
@@ -219,6 +215,22 @@ void redisLog(int level, const char *fmt, ...) {
if
(
server
.
syslog_enabled
)
syslog
(
syslogLevelMap
[
level
],
"%s"
,
msg
);
}
/* Like redisLogRaw() but with printf-alike support. This is the funciton that
* is used across the code. The raw version is only used in order to dump
* the INFO output on crash. */
void
redisLog
(
int
level
,
const
char
*
fmt
,
...)
{
va_list
ap
;
char
msg
[
REDIS_MAX_LOGMSG_LEN
];
if
(
level
<
server
.
verbosity
)
return
;
va_start
(
ap
,
fmt
);
vsnprintf
(
msg
,
sizeof
(
msg
),
fmt
,
ap
);
va_end
(
ap
);
redisLogRaw
(
level
,
msg
);
}
/* Redis generally does not try to recover from out of memory conditions
* when allocating objects or strings, it is not clear if it will be possible
* to report this condition to the client since the networking layer itself
...
...
@@ -1725,7 +1737,7 @@ void segvHandler(int sig, siginfo_t *info, void *secret) {
redisLog
(
REDIS_WARNING
,
"======= Ooops! Redis %s got signal: -%d- ======="
,
REDIS_VERSION
,
sig
);
infostring
=
genRedisInfoString
(
"all"
);
redisLog
(
REDIS_WARNING
,
"%s"
,
infostring
);
redisLog
Raw
(
REDIS_WARNING
,
infostring
);
/* It's not safe to sdsfree() the returned string under memory
* corruption conditions. Let it leak as we are going to abort */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录