Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trackrdrd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
trackrdrd
Commits
ff635a12
Commit
ff635a12
authored
Dec 15, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kafka mq plugin uses ISO 8601 format for the timestamp in its log
parent
af50de08
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
log.c
src/mq/kafka/log.c
+19
-5
No files found.
src/mq/kafka/log.c
View file @
ff635a12
...
...
@@ -35,9 +35,12 @@
#include <errno.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include "mq_kafka.h"
#define ISO8601_LEN (sizeof("YYYY-MM-DDTHH:mm:SS.012345") + 1)
static
int
lvl
=
LOG_INFO
;
static
const
char
*
level2name
[
LOG_DEBUG
+
1
];
static
FILE
*
out
=
NULL
;
...
...
@@ -58,16 +61,27 @@ init_lvlnames(void)
void
MQ_LOG_Log
(
int
level
,
const
char
*
msg
,
...)
{
time_t
t
;
char
timestr
[
26
];
struct
timeval
tv
;
struct
tm
tm
;
char
buf
[
ISO8601_LEN
],
timestr
[
ISO8601_LEN
];
va_list
ap
;
if
(
level
>
lvl
||
out
==
NULL
)
return
;
t
=
time
(
NULL
);
ctime_r
(
&
t
,
timestr
);
timestr
[
24
]
=
'\0'
;
/* cf. VTIM_real() and VTIM_timeval() in vtim.c */
#ifdef HAVE_CLOCK_GETTIME
struct
timespec
ts
;
AZ
(
clock_gettime
(
CLOCK_REALTIME
,
&
ts
));
tv
.
tv_sec
=
ts
.
tv_sec
;
tv
.
tv_usec
=
(
int
)(
1e3
*
ts
.
tv_nsec
);
#else
AZ
(
gettimeofday
(
&
tv
,
NULL
));
#endif
AN
(
localtime_r
(
&
tv
.
tv_sec
,
&
tm
));
strftime
(
buf
,
sizeof
(
buf
),
"%FT%T.%%06u"
,
&
tm
);
snprintf
(
timestr
,
sizeof
(
timestr
),
buf
,
tv
.
tv_usec
);
flockfile
(
out
);
fprintf
(
out
,
"%s [%s]: "
,
timestr
,
level2name
[
level
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment