Skip to content

Commit 924deb8

Browse files
authored
Merge pull request #83 from JamesWrigley/large-resolutions
Use custom_isless() to compare all timescales from the user
2 parents 90e6cfa + 596ae86 commit 924deb8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Sinks/datetime_rotation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function next_datetime_transition(fmt::DateFormat)
126126

127127
tokens = filter(t -> isa(t, Dates.DatePart), collect(fmt.tokens))
128128
minimum_timescale = first(sort(map(t -> token_timescales[extract_token(t)], tokens), lt=custom_isless))
129-
if minimum_timescale < Minute(1)
129+
if custom_isless(minimum_timescale, Minute(1))
130130
throw(ArgumentError("rotating the logger with sub-minute resolution not supported"))
131131
end
132132
return ceil(now(), minimum_timescale)

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ end
189189
l1 = DatetimeRotatingFileLogger(dir, dateformat"yyyy-mm-dd.\l\o\g")
190190
l2 = DatetimeRotatingFileLogger(identity, dir, dateformat"yyyy-mm-dd.\l\o\g")
191191
@test l.filename_pattern == l1.filename_pattern == l2.filename_pattern
192+
193+
# Test large resolutions, which have some weirdness related to ordering
194+
# (see next_datetime_transition()). These should not throw.
195+
DatetimeRotatingFileLogger(dir, raw"yyyy-mm.\l\o\g")
196+
DatetimeRotatingFileLogger(dir, raw"yyyy.\l\o\g")
192197
end
193198
end
194199

0 commit comments

Comments
 (0)