diff --git a/man/systemctl.xml b/man/systemctl.xml index 506f9ca68f..bb3a296645 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -2134,6 +2134,20 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err + + + + + Takes one of pretty (the default), + us, µs, utc. + Changes the format of printed timestamps. + pretty: Day YYYY-MM-DD HH:MM:SS TZ + us or µs: Day YYYY-MM-DD HH:MM:SS.UUUUUU TZ + utc: Day YYYY-MM-DD HH:MM:SS UTC + us+utc or µs+utc: Day YYYY-MM-DD HH:MM:SS.UUUUUU UTC + + + diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index fdbe32e5f7..b5bd727abf 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -127,7 +127,7 @@ _systemctl () { --quiet -q --system --user --version --runtime --recursive -r --firmware-setup --show-types -i --ignore-inhibitors --plain --failed --value --fail --dry-run --wait' [ARG]='--host -H --kill-who --property -p --signal -s --type -t --state --job-mode --root - --preset-mode -n --lines -o --output -M --machine --message' + --preset-mode -n --lines -o --output -M --machine --message --timestamp' ) if __contains_word "--user" ${COMP_WORDS[*]}; then @@ -176,6 +176,9 @@ _systemctl () { --machine|-M) comps=$( __get_machines ) ;; + --timestamp) + comps='pretty us µs utc us+utc µs+utc' + ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in index 582d469c35..c59beb157c 100644 --- a/shell-completion/zsh/_systemctl.in +++ b/shell-completion/zsh/_systemctl.in @@ -431,6 +431,13 @@ done _values -s , "${_modes[@]}" } +(( $+functions[_systemctl_timestamp] )) || + _systemctl_timestamp() { + local -a _styles + _styles=(help pretty us µs utc us+utc µs+utc) + _values -s , "${_styles[@]}" + } + # Build arguments for "systemctl" to be used in completion. local -a _modes; _modes=("--user" "--system") # Use the last mode (they are exclusive and the last one is used). @@ -471,4 +478,5 @@ _arguments -s \ '--firmware-setup[Tell the firmware to show the setup menu on next boot]' \ '--plain[When used with list-dependencies, print output as a list]' \ '--failed[Show failed units]' \ + '--timestamp=[Change format of printed timestamps]:style:_systemctl_timestamp' \ '*::systemctl command:_systemctl_commands' diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 15cc1b8851..0958f251ea 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -23,6 +23,7 @@ #include "path-util.h" #include "process-util.h" #include "stat-util.h" +#include "string-table.h" #include "string-util.h" #include "strv.h" #include "time-util.h" @@ -282,12 +283,11 @@ struct timeval *timeval_store(struct timeval *tv, usec_t u) { return tv; } -static char *format_timestamp_internal( +char *format_timestamp_style( char *buf, size_t l, usec_t t, - bool utc, - bool us) { + TimestampStyle style) { /* The weekdays in non-localized (English) form. We use this instead of the localized form, so that our * generated timestamps may be parsed with parse_timestamp(), and always read the same. */ @@ -304,9 +304,27 @@ static char *format_timestamp_internal( struct tm tm; time_t sec; size_t n; + bool utc = false, us = false; assert(buf); + switch (style) { + case TIMESTAMP_PRETTY: + break; + case TIMESTAMP_US: + us = true; + break; + case TIMESTAMP_UTC: + utc = true; + break; + case TIMESTAMP_US_UTC: + us = true; + utc = true; + break; + default: + return NULL; + } + if (l < (size_t) (3 + /* week day */ 1 + 10 + /* space and date */ 1 + 8 + /* space and time */ @@ -380,22 +398,6 @@ static char *format_timestamp_internal( return buf; } -char *format_timestamp(char *buf, size_t l, usec_t t) { - return format_timestamp_internal(buf, l, t, false, false); -} - -char *format_timestamp_utc(char *buf, size_t l, usec_t t) { - return format_timestamp_internal(buf, l, t, true, false); -} - -char *format_timestamp_us(char *buf, size_t l, usec_t t) { - return format_timestamp_internal(buf, l, t, false, true); -} - -char *format_timestamp_us_utc(char *buf, size_t l, usec_t t) { - return format_timestamp_internal(buf, l, t, true, true); -} - char *format_timestamp_relative(char *buf, size_t l, usec_t t) { const char *s; usec_t n, d; @@ -1568,3 +1570,27 @@ int time_change_fd(void) { return -errno; } + +static const char* const timestamp_style_table[_TIMESTAMP_STYLE_MAX] = { + [TIMESTAMP_PRETTY] = "pretty", + [TIMESTAMP_US] = "us", + [TIMESTAMP_UTC] = "utc", + [TIMESTAMP_US_UTC] = "us+utc", +}; + +/* Use the macro for enum → string to allow for aliases */ +_DEFINE_STRING_TABLE_LOOKUP_TO_STRING(timestamp_style, TimestampStyle,); + +/* For the string → enum mapping we use the generic implementation, but also support two aliases */ +TimestampStyle timestamp_style_from_string(const char *s) { + TimestampStyle t; + + t = (TimestampStyle) string_table_lookup(timestamp_style_table, ELEMENTSOF(timestamp_style_table), s); + if (t >= 0) + return t; + if (streq_ptr(s, "µs")) + return TIMESTAMP_US; + if (streq_ptr(s, "µs+uts")) + return TIMESTAMP_US_UTC; + return t; +} diff --git a/src/basic/time-util.h b/src/basic/time-util.h index 9bbe986306..b181a6b3b4 100644 --- a/src/basic/time-util.h +++ b/src/basic/time-util.h @@ -29,6 +29,15 @@ typedef struct triple_timestamp { usec_t boottime; } triple_timestamp; +typedef enum TimestampStyle { + TIMESTAMP_PRETTY, + TIMESTAMP_US, + TIMESTAMP_UTC, + TIMESTAMP_US_UTC, + _TIMESTAMP_STYLE_MAX, + _TIMESTAMP_STYLE_INVALID = -1, +} TimestampStyle; + #define USEC_INFINITY ((usec_t) UINT64_MAX) #define NSEC_INFINITY ((nsec_t) UINT64_MAX) @@ -107,13 +116,14 @@ struct timespec *timespec_store(struct timespec *ts, usec_t u); usec_t timeval_load(const struct timeval *tv) _pure_; struct timeval *timeval_store(struct timeval *tv, usec_t u); -char *format_timestamp(char *buf, size_t l, usec_t t); -char *format_timestamp_utc(char *buf, size_t l, usec_t t); -char *format_timestamp_us(char *buf, size_t l, usec_t t); -char *format_timestamp_us_utc(char *buf, size_t l, usec_t t); +char *format_timestamp_style(char *buf, size_t l, usec_t t, TimestampStyle style); char *format_timestamp_relative(char *buf, size_t l, usec_t t); char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy); +static inline char *format_timestamp(char *buf, size_t l, usec_t t) { + return format_timestamp_style(buf, l, t, TIMESTAMP_PRETTY); +} + int parse_timestamp(const char *t, usec_t *usec); int parse_sec(const char *t, usec_t *usec); @@ -185,3 +195,6 @@ static inline usec_t usec_sub_signed(usec_t timestamp, int64_t delta) { #endif int time_change_fd(void); + +const char* timestamp_style_to_string(TimestampStyle t) _const_; +TimestampStyle timestamp_style_from_string(const char *s) _pure_; diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 094499f47b..9d0048b8bc 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -265,7 +265,7 @@ get_parent: static char *format_timestamp_maybe_utc(char *buf, size_t l, usec_t t) { if (arg_utc) - return format_timestamp_utc(buf, l, t); + return format_timestamp_style(buf, l, t, TIMESTAMP_UTC); return format_timestamp(buf, l, t); } diff --git a/src/shared/format-table.c b/src/shared/format-table.c index 87ef5c3f00..7e876295ff 100644 --- a/src/shared/format-table.c +++ b/src/shared/format-table.c @@ -1335,7 +1335,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas if (d->type == TABLE_TIMESTAMP) ret = format_timestamp(p, FORMAT_TIMESTAMP_MAX, d->timestamp); else if (d->type == TABLE_TIMESTAMP_UTC) - ret = format_timestamp_utc(p, FORMAT_TIMESTAMP_MAX, d->timestamp); + ret = format_timestamp_style(p, FORMAT_TIMESTAMP_MAX, d->timestamp, TIMESTAMP_UTC); else ret = format_timestamp_relative(p, FORMAT_TIMESTAMP_MAX, d->timestamp); if (!ret) diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 780ac508ce..979c9b3f29 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -368,7 +368,7 @@ static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, Ou const char *k; if (flags & OUTPUT_UTC) - k = format_timestamp_utc(buf, sizeof(buf), x); + k = format_timestamp_style(buf, sizeof(buf), x, TIMESTAMP_UTC); else k = format_timestamp(buf, sizeof(buf), x); if (!k) @@ -685,8 +685,8 @@ static int output_verbose( if (r < 0) return log_error_errno(r, "Failed to get cursor: %m"); - timestamp = flags & OUTPUT_UTC ? format_timestamp_us_utc(ts, sizeof ts, realtime) - : format_timestamp_us(ts, sizeof ts, realtime); + timestamp = format_timestamp_style(ts, sizeof ts, realtime, + flags & OUTPUT_UTC ? TIMESTAMP_US_UTC : TIMESTAMP_US); fprintf(f, "%s [%s]\n", timestamp ?: "(no timestamp)", cursor); diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 6e6e1810a0..032932fd77 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -170,6 +170,7 @@ static bool arg_now = false; static bool arg_jobs_before = false; static bool arg_jobs_after = false; static char **arg_clean_what = NULL; +static TimestampStyle arg_timestamp_style = TIMESTAMP_PRETTY; /* This is a global cache that will be constructed on first use. */ static Hashmap *cached_id_map = NULL; @@ -4195,7 +4196,7 @@ static void print_status_info( i->active_exit_timestamp; s1 = format_timestamp_relative(since1, sizeof(since1), timestamp); - s2 = format_timestamp(since2, sizeof(since2), timestamp); + s2 = format_timestamp_style(since2, sizeof(since2), timestamp, arg_timestamp_style); if (s1) printf(" since %s; %s\n", s2, s1); @@ -4229,7 +4230,7 @@ static void print_status_info( dual_timestamp_get(&nw); next_elapse = calc_next_elapse(&nw, &next); next_rel_time = format_timestamp_relative(tstamp1, sizeof tstamp1, next_elapse); - next_time = format_timestamp(tstamp2, sizeof tstamp2, next_elapse); + next_time = format_timestamp_style(tstamp2, sizeof tstamp2, next_elapse, arg_timestamp_style); if (next_time && next_rel_time) printf("%s; %s\n", next_time, next_rel_time); @@ -4254,7 +4255,7 @@ static void print_status_info( int n = 0; s1 = format_timestamp_relative(since1, sizeof(since1), i->condition_timestamp); - s2 = format_timestamp(since2, sizeof(since2), i->condition_timestamp); + s2 = format_timestamp_style(since2, sizeof(since2), i->condition_timestamp, arg_timestamp_style); printf(" Condition: start %scondition failed%s at %s%s%s\n", ansi_highlight_yellow(), ansi_normal(), @@ -4276,7 +4277,7 @@ static void print_status_info( if (!i->assert_result && i->assert_timestamp > 0) { s1 = format_timestamp_relative(since1, sizeof(since1), i->assert_timestamp); - s2 = format_timestamp(since2, sizeof(since2), i->assert_timestamp); + s2 = format_timestamp_style(since2, sizeof(since2), i->assert_timestamp, arg_timestamp_style); printf(" Assert: start %sassertion failed%s at %s%s%s\n", ansi_highlight_red(), ansi_normal(), @@ -5037,7 +5038,7 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m while ((r = sd_bus_message_read(m, "(sst)", &base, &spec, &next_elapse)) > 0) { char timestamp[FORMAT_TIMESTAMP_MAX] = "n/a"; - (void) format_timestamp(timestamp, sizeof(timestamp), next_elapse); + (void) format_timestamp_style(timestamp, sizeof(timestamp), next_elapse, arg_timestamp_style); bus_print_property_valuef(name, expected_value, value, "{ %s=%s ; next_elapse=%s }", base, spec, timestamp); } @@ -5077,8 +5078,8 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m strna(info.path), strna(tt), strna(o), - strna(format_timestamp(timestamp1, sizeof(timestamp1), info.start_timestamp)), - strna(format_timestamp(timestamp2, sizeof(timestamp2), info.exit_timestamp)), + strna(format_timestamp_style(timestamp1, sizeof(timestamp1), info.start_timestamp, arg_timestamp_style)), + strna(format_timestamp_style(timestamp2, sizeof(timestamp2), info.exit_timestamp, arg_timestamp_style)), info.pid, sigchld_code_to_string(info.code), info.status, @@ -5090,8 +5091,8 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m strna(info.path), strna(tt), yes_no(info.ignore), - strna(format_timestamp(timestamp1, sizeof(timestamp1), info.start_timestamp)), - strna(format_timestamp(timestamp2, sizeof(timestamp2), info.exit_timestamp)), + strna(format_timestamp_style(timestamp1, sizeof(timestamp1), info.start_timestamp, arg_timestamp_style)), + strna(format_timestamp_style(timestamp2, sizeof(timestamp2), info.exit_timestamp, arg_timestamp_style)), info.pid, sigchld_code_to_string(info.code), info.status, @@ -5754,7 +5755,7 @@ static int show_system_status(sd_bus *bus) { printf(" Failed: %" PRIu32 " units\n", mi.n_failed_units); printf(" Since: %s; %s\n", - format_timestamp(since2, sizeof(since2), mi.timestamp), + format_timestamp_style(since2, sizeof(since2), mi.timestamp, arg_timestamp_style), format_timestamp_relative(since1, sizeof(since1), mi.timestamp)); printf(" CGroup: %s\n", mi.control_group ?: "/"); @@ -7804,6 +7805,11 @@ static int systemctl_help(void) { " --boot-loader-entry=NAME\n" " Boot into a specific boot loader entry on next boot\n" " --plain Print unit dependencies as a list instead of a tree\n" + " --timestamp=FORMAT Change format of printed timestamps.\n" + " 'pretty' (default): 'Day YYYY-MM-DD HH:MM:SS TZ\n" + " 'us': 'Day YYYY-MM-DD HH:MM:SS.UUUUUU TZ\n" + " 'utc': 'Day YYYY-MM-DD HH:MM:SS UTC\n" + " 'us+utc': 'Day YYYY-MM-DD HH:MM:SS.UUUUUU UTC\n" "\nSee the %2$s for details.\n" , program_invocation_short_name , link @@ -8052,6 +8058,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { ARG_WAIT, ARG_WHAT, ARG_REBOOT_ARG, + ARG_TIMESTAMP_STYLE, }; static const struct option options[] = { @@ -8106,6 +8113,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { { "show-transaction", no_argument, NULL, 'T' }, { "what", required_argument, NULL, ARG_WHAT }, { "reboot-argument", required_argument, NULL, ARG_REBOOT_ARG }, + { "timestamp", required_argument, NULL, ARG_TIMESTAMP_STYLE }, {} }; @@ -8505,6 +8513,19 @@ static int systemctl_parse_argv(int argc, char *argv[]) { arg_reboot_argument = optarg; break; + case ARG_TIMESTAMP_STYLE: + if (streq(optarg, "help")) { + DUMP_STRING_TABLE(timestamp_style, TimestampStyle, _TIMESTAMP_STYLE_MAX); + return 0; + } + + arg_timestamp_style = timestamp_style_from_string(optarg); + if (arg_timestamp_style < 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Invalid value: %s.", optarg); + + break; + case '.': /* Output an error mimicking getopt, and print a hint afterwards */ log_error("%s: invalid option -- '.'", program_invocation_name); @@ -9130,7 +9151,7 @@ static int logind_schedule_shutdown(void) { return log_warning_errno(r, "Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: %s", bus_error_message(&error, r)); if (!arg_quiet) - log_info("%s scheduled for %s, use 'shutdown -c' to cancel.", log_action, format_timestamp(date, sizeof(date), arg_when)); + log_info("%s scheduled for %s, use 'shutdown -c' to cancel.", log_action, format_timestamp_style(date, sizeof(date), arg_when, arg_timestamp_style)); return 0; #else return log_error_errno(SYNTHETIC_ERRNO(ENOSYS), diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c index 9e2ae55ab6..d566638d5d 100644 --- a/src/test/test-calendarspec.c +++ b/src/test/test-calendarspec.c @@ -58,7 +58,7 @@ static void test_next(const char *input, const char *new_tz, usec_t after, usec_ u = after; r = calendar_spec_next_usec(c, after, &u); - printf("At: %s\n", r < 0 ? strerror_safe(r) : format_timestamp_us(buf, sizeof buf, u)); + printf("At: %s\n", r < 0 ? strerror_safe(r) : format_timestamp_style(buf, sizeof buf, u, TIMESTAMP_US)); if (expect != (usec_t)-1) assert_se(r >= 0 && u == expect); else @@ -83,7 +83,7 @@ static void test_timestamp(void) { x = now(CLOCK_REALTIME); - assert_se(format_timestamp_us(buf, sizeof(buf), x)); + assert_se(format_timestamp_style(buf, sizeof(buf), x, TIMESTAMP_US)); printf("%s\n", buf); assert_se(calendar_spec_from_string(buf, &c) >= 0); assert_se(calendar_spec_to_string(c, &t) >= 0); @@ -104,11 +104,11 @@ static void test_hourly_bug_4031(void) { n = now(CLOCK_REALTIME); assert_se((r = calendar_spec_next_usec(c, n, &u)) >= 0); - printf("Now: %s (%"PRIu64")\n", format_timestamp_us(buf, sizeof buf, n), n); - printf("Next hourly: %s (%"PRIu64")\n", r < 0 ? strerror_safe(r) : format_timestamp_us(buf, sizeof buf, u), u); + printf("Now: %s (%"PRIu64")\n", format_timestamp_style(buf, sizeof buf, n, TIMESTAMP_US), n); + printf("Next hourly: %s (%"PRIu64")\n", r < 0 ? strerror_safe(r) : format_timestamp_style(buf, sizeof buf, u, TIMESTAMP_US), u); assert_se((r = calendar_spec_next_usec(c, u, &w)) >= 0); - printf("Next hourly: %s (%"PRIu64")\n", r < 0 ? strerror_safe(r) : format_timestamp_us(zaf, sizeof zaf, w), w); + printf("Next hourly: %s (%"PRIu64")\n", r < 0 ? strerror_safe(r) : format_timestamp_style(zaf, sizeof zaf, w, TIMESTAMP_US), w); assert_se(n < u); assert_se(u <= n + USEC_PER_HOUR); diff --git a/src/test/test-date.c b/src/test/test-date.c index 7d27cfa703..f39eca6176 100644 --- a/src/test/test-date.c +++ b/src/test/test-date.c @@ -11,7 +11,7 @@ static void test_should_pass(const char *p) { log_info("Test: %s", p); assert_se(parse_timestamp(p, &t) >= 0); - assert_se(format_timestamp_us(buf, sizeof(buf), t)); + assert_se(format_timestamp_style(buf, sizeof(buf), t, TIMESTAMP_US)); log_info("\"%s\" → \"%s\"", p, buf); assert_se(parse_timestamp(buf, &q) >= 0); @@ -19,7 +19,7 @@ static void test_should_pass(const char *p) { char tmp[FORMAT_TIMESTAMP_MAX]; log_error("round-trip failed: \"%s\" → \"%s\"", - buf, format_timestamp_us(tmp, sizeof(tmp), q)); + buf, format_timestamp_style(tmp, sizeof(tmp), q, TIMESTAMP_US)); } assert_se(q == t); diff --git a/src/test/test-time-util.c b/src/test/test-time-util.c index 8826956d10..64242951ac 100644 --- a/src/test/test-time-util.c +++ b/src/test/test-time-util.c @@ -333,17 +333,17 @@ static void test_format_timestamp(void) { assert_se(parse_timestamp(buf, &y) >= 0); assert_se(x / USEC_PER_SEC == y / USEC_PER_SEC); - assert_se(format_timestamp_utc(buf, sizeof(buf), x)); + assert_se(format_timestamp_style(buf, sizeof(buf), x, TIMESTAMP_UTC)); log_info("%s", buf); assert_se(parse_timestamp(buf, &y) >= 0); assert_se(x / USEC_PER_SEC == y / USEC_PER_SEC); - assert_se(format_timestamp_us(buf, sizeof(buf), x)); + assert_se(format_timestamp_style(buf, sizeof(buf), x, TIMESTAMP_US)); log_info("%s", buf); assert_se(parse_timestamp(buf, &y) >= 0); assert_se(x == y); - assert_se(format_timestamp_us_utc(buf, sizeof(buf), x)); + assert_se(format_timestamp_style(buf, sizeof(buf), x, TIMESTAMP_US_UTC)); log_info("%s", buf); assert_se(parse_timestamp(buf, &y) >= 0); assert_se(x == y); @@ -364,7 +364,7 @@ static void test_format_timestamp_utc_one(usec_t val, const char *result) { char buf[FORMAT_TIMESTAMP_MAX]; const char *t; - t = format_timestamp_utc(buf, sizeof(buf), val); + t = format_timestamp_style(buf, sizeof(buf), val, TIMESTAMP_UTC); assert_se(streq_ptr(t, result)); } diff --git a/src/time-wait-sync/time-wait-sync.c b/src/time-wait-sync/time-wait-sync.c index e880f9e6b6..96072445f6 100644 --- a/src/time-wait-sync/time-wait-sync.c +++ b/src/time-wait-sync/time-wait-sync.c @@ -155,7 +155,7 @@ static int clock_state_update( if (tx.status & STA_NANO) tx.time.tv_usec /= 1000; t = timeval_load(&tx.time); - ts = format_timestamp_us_utc(buf, sizeof(buf), t); + ts = format_timestamp_style(buf, sizeof(buf), t, TIMESTAMP_US_UTC); if (!ts) strcpy(buf, "unrepresentable"); log_info("adjtime state %d status %x time %s", sp->adjtime_state, tx.status, ts); diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 616a54b3c3..437b8bb449 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -611,7 +611,7 @@ static int dir_cleanup( /* Follows spelling in stat(1). */ log_debug("Directory \"%s\": modify time %s is too new.", sub_path, - format_timestamp_us(a, sizeof(a), age)); + format_timestamp_style(a, sizeof(a), age, TIMESTAMP_US)); continue; } @@ -620,7 +620,7 @@ static int dir_cleanup( char a[FORMAT_TIMESTAMP_MAX]; log_debug("Directory \"%s\": access time %s is too new.", sub_path, - format_timestamp_us(a, sizeof(a), age)); + format_timestamp_style(a, sizeof(a), age, TIMESTAMP_US)); continue; } @@ -672,7 +672,7 @@ static int dir_cleanup( /* Follows spelling in stat(1). */ log_debug("File \"%s\": modify time %s is too new.", sub_path, - format_timestamp_us(a, sizeof(a), age)); + format_timestamp_style(a, sizeof(a), age, TIMESTAMP_US)); continue; } @@ -681,7 +681,7 @@ static int dir_cleanup( char a[FORMAT_TIMESTAMP_MAX]; log_debug("File \"%s\": access time %s is too new.", sub_path, - format_timestamp_us(a, sizeof(a), age)); + format_timestamp_style(a, sizeof(a), age, TIMESTAMP_US)); continue; } @@ -690,7 +690,7 @@ static int dir_cleanup( char a[FORMAT_TIMESTAMP_MAX]; log_debug("File \"%s\": change time %s is too new.", sub_path, - format_timestamp_us(a, sizeof(a), age)); + format_timestamp_style(a, sizeof(a), age, TIMESTAMP_US)); continue; } @@ -713,8 +713,8 @@ finish: log_debug("Restoring access and modification time on \"%s\": %s, %s", p, - format_timestamp_us(a, sizeof(a), age1), - format_timestamp_us(b, sizeof(b), age2)); + format_timestamp_style(a, sizeof(a), age1, TIMESTAMP_US), + format_timestamp_style(b, sizeof(b), age2, TIMESTAMP_US)); /* Restore original directory timestamps */ if (futimens(dirfd(d), (struct timespec[]) { @@ -2228,7 +2228,7 @@ static int clean_item_instance(Item *i, const char* instance) { log_debug("Cleanup threshold for %s \"%s\" is %s", mountpoint ? "mount point" : "directory", instance, - format_timestamp_us(timestamp, sizeof(timestamp), cutoff)); + format_timestamp_style(timestamp, sizeof(timestamp), cutoff, TIMESTAMP_US)); return dir_cleanup(i, instance, d, &s, cutoff, s.st_dev, mountpoint, MAX_DEPTH, i->keep_first_level);