mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
27 lines
948 B
Diff
27 lines
948 B
Diff
diff --git a/plugins/out_file/file.c b/plugins/out_file/file.c
|
|
index 77baf6be8..04c519d5a 100644
|
|
--- a/plugins/out_file/file.c
|
|
+++ b/plugins/out_file/file.c
|
|
@@ -238,10 +238,20 @@ static int template_output_write(struct flb_file_conf *ctx,
|
|
|
|
/*
|
|
* Right now we treat "{time}" specially and fill the placeholder
|
|
- * with the metadata timestamp (formatted as float).
|
|
+ * with the metadata timestamp.
|
|
*/
|
|
if (!strncmp(key, "time", size)) {
|
|
- fprintf(fp, "%f", flb_time_to_double(tm));
|
|
+ struct tm tm_local;
|
|
+ char buf[32];
|
|
+ if (localtime_r(&tm->tm.tv_sec, &tm_local) == NULL) {
|
|
+ flb_plg_error(ctx->ins, "localtime_r failed");
|
|
+ return -1;
|
|
+ }
|
|
+ if (strftime(buf, sizeof(buf), "%b %d %H:%M:%S", &tm_local) == 0) {
|
|
+ flb_plg_error(ctx->ins, "strftime failed");
|
|
+ return -1;
|
|
+ }
|
|
+ fputs(buf, fp);
|
|
return 0;
|
|
}
|
|
|