Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
3e00496d
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3e00496d
编写于
10月 17, 2008
作者:
A
Alvaro Herrera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor some duplicate code to set up formatted_log_time and
formatted_start_time.
上级
e4fb8ff0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
72 deletion
+62
-72
src/backend/utils/error/elog.c
src/backend/utils/error/elog.c
+62
-72
未找到文件。
src/backend/utils/error/elog.c
浏览文件 @
3e00496d
...
...
@@ -42,7 +42,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.20
7 2008/10/09 17:24:05
alvherre Exp $
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.20
8 2008/10/17 22:56:16
alvherre Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -146,6 +146,8 @@ static void append_with_tabs(StringInfo buf, const char *str);
static
bool
is_log_level_output
(
int
elevel
,
int
log_min_level
);
static
void
write_pipe_chunks
(
char
*
data
,
int
len
,
int
dest
);
static
void
write_csvlog
(
ErrorData
*
edata
);
static
void
setup_formatted_log_time
(
void
);
static
void
setup_formatted_start_time
(
void
);
/*
* errstart --- begin an error-reporting cycle
...
...
@@ -1481,6 +1483,60 @@ write_eventlog(int level, const char *line)
}
#endif
/* WIN32 */
/*
* setup formatted_log_time, for consistent times between CSV and regular logs
*/
static
void
setup_formatted_log_time
(
void
)
{
struct
timeval
tv
;
pg_time_t
stamp_time
;
pg_tz
*
tz
;
char
msbuf
[
8
];
gettimeofday
(
&
tv
,
NULL
);
stamp_time
=
(
pg_time_t
)
tv
.
tv_sec
;
/*
* Normally we print log timestamps in log_timezone, but during startup we
* could get here before that's set. If so, fall back to gmt_timezone
* (which guc.c ensures is set up before Log_line_prefix can become
* nonempty).
*/
tz
=
log_timezone
?
log_timezone
:
gmt_timezone
;
pg_strftime
(
formatted_log_time
,
FORMATTED_TS_LEN
,
/* leave room for milliseconds... */
"%Y-%m-%d %H:%M:%S %Z"
,
pg_localtime
(
&
stamp_time
,
tz
));
/* 'paste' milliseconds into place... */
sprintf
(
msbuf
,
".%03d"
,
(
int
)
(
tv
.
tv_usec
/
1000
));
strncpy
(
formatted_log_time
+
19
,
msbuf
,
4
);
}
/*
* setup formatted_start_time
*/
static
void
setup_formatted_start_time
(
void
)
{
pg_time_t
stamp_time
=
(
pg_time_t
)
MyStartTime
;
pg_tz
*
tz
;
/*
* Normally we print log timestamps in log_timezone, but during startup we
* could get here before that's set. If so, fall back to gmt_timezone
* (which guc.c ensures is set up before Log_line_prefix can become
* nonempty).
*/
tz
=
log_timezone
?
log_timezone
:
gmt_timezone
;
pg_strftime
(
formatted_start_time
,
FORMATTED_TS_LEN
,
"%Y-%m-%d %H:%M:%S %Z"
,
pg_localtime
(
&
stamp_time
,
tz
));
}
/*
* Format tag info for log lines; append to the provided buffer.
*/
...
...
@@ -1561,34 +1617,8 @@ log_line_prefix(StringInfo buf)
appendStringInfo
(
buf
,
"%ld"
,
log_line_number
);
break
;
case
'm'
:
{
struct
timeval
tv
;
pg_time_t
stamp_time
;
pg_tz
*
tz
;
char
msbuf
[
8
];
gettimeofday
(
&
tv
,
NULL
);
stamp_time
=
(
pg_time_t
)
tv
.
tv_sec
;
/*
* Normally we print log timestamps in log_timezone, but
* during startup we could get here before that's set. If
* so, fall back to gmt_timezone (which guc.c ensures is
* set up before Log_line_prefix can become nonempty).
*/
tz
=
log_timezone
?
log_timezone
:
gmt_timezone
;
pg_strftime
(
formatted_log_time
,
FORMATTED_TS_LEN
,
/* leave room for milliseconds... */
"%Y-%m-%d %H:%M:%S %Z"
,
pg_localtime
(
&
stamp_time
,
tz
));
/* 'paste' milliseconds into place... */
sprintf
(
msbuf
,
".%03d"
,
(
int
)
(
tv
.
tv_usec
/
1000
));
strncpy
(
formatted_log_time
+
19
,
msbuf
,
4
);
appendStringInfoString
(
buf
,
formatted_log_time
);
}
setup_formatted_log_time
();
appendStringInfoString
(
buf
,
formatted_log_time
);
break
;
case
't'
:
{
...
...
@@ -1606,16 +1636,7 @@ log_line_prefix(StringInfo buf)
break
;
case
's'
:
if
(
formatted_start_time
[
0
]
==
'\0'
)
{
pg_time_t
stamp_time
=
(
pg_time_t
)
MyStartTime
;
pg_tz
*
tz
;
tz
=
log_timezone
?
log_timezone
:
gmt_timezone
;
pg_strftime
(
formatted_start_time
,
FORMATTED_TS_LEN
,
"%Y-%m-%d %H:%M:%S %Z"
,
pg_localtime
(
&
stamp_time
,
tz
));
}
setup_formatted_start_time
();
appendStringInfoString
(
buf
,
formatted_start_time
);
break
;
case
'i'
:
...
...
@@ -1731,32 +1752,8 @@ write_csvlog(ErrorData *edata)
* to put same timestamp in both syslog and csvlog messages.
*/
if
(
formatted_log_time
[
0
]
==
'\0'
)
{
struct
timeval
tv
;
pg_time_t
stamp_time
;
pg_tz
*
tz
;
char
msbuf
[
8
];
gettimeofday
(
&
tv
,
NULL
);
stamp_time
=
(
pg_time_t
)
tv
.
tv_sec
;
/*
* Normally we print log timestamps in log_timezone, but during
* startup we could get here before that's set. If so, fall back to
* gmt_timezone (which guc.c ensures is set up before Log_line_prefix
* can become nonempty).
*/
tz
=
log_timezone
?
log_timezone
:
gmt_timezone
;
pg_strftime
(
formatted_log_time
,
FORMATTED_TS_LEN
,
/* leave room for milliseconds... */
"%Y-%m-%d %H:%M:%S %Z"
,
pg_localtime
(
&
stamp_time
,
tz
));
setup_formatted_log_time
();
/* 'paste' milliseconds into place... */
sprintf
(
msbuf
,
".%03d"
,
(
int
)
(
tv
.
tv_usec
/
1000
));
strncpy
(
formatted_log_time
+
19
,
msbuf
,
4
);
}
appendStringInfoString
(
&
buf
,
formatted_log_time
);
appendStringInfoChar
(
&
buf
,
','
);
...
...
@@ -1813,14 +1810,7 @@ write_csvlog(ErrorData *edata)
/* session start timestamp */
if
(
formatted_start_time
[
0
]
==
'\0'
)
{
pg_time_t
stamp_time
=
(
pg_time_t
)
MyStartTime
;
pg_tz
*
tz
=
log_timezone
?
log_timezone
:
gmt_timezone
;
pg_strftime
(
formatted_start_time
,
FORMATTED_TS_LEN
,
"%Y-%m-%d %H:%M:%S %Z"
,
pg_localtime
(
&
stamp_time
,
tz
));
}
setup_formatted_start_time
();
appendStringInfoString
(
&
buf
,
formatted_start_time
);
appendStringInfoChar
(
&
buf
,
','
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录