Skip to content

Commit

Permalink
timestamp formatting bug (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
odygrd committed Jul 24, 2023
1 parent 9d0343f commit ba554dd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
Quill ERROR: [format: "Support for floats {:.{}f}", error: "precision is not integer"]
```

- Fixed a bug in timestamp formatting that occasionally displayed an hour component of 24 as
0. ([#329](https://github.com/odygrd/quill/pull/329))

- Added support for specifying a runtime log level, allowing dynamic log level configuration at runtime.
The new runtime log level feature provides flexibility when needed, with a minor overhead cost.
It is recommended to continue using the existing static log level macros for optimal
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,14 @@ To build Quill as a shared library (DLL) on Windows, follow these steps:
2. Additionally, you need to define `QUILL_BUILD_SHARED` either in your code before including `Quill.h` or as a compiler
flag when building outside of CMake.

#### Building Quill for Android NDK

To build Quill for Android NDK add the following CMake flags when configuring the build:

```
-DQUILL_NO_THREAD_NAME_SUPPORT:BOOL=ON
```

## Design

![design.jpg](docs%2Fdesign.jpg)
Expand Down
1 change: 1 addition & 0 deletions quill/include/quill/handlers/Handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Handler

/**
* Set a custom formatter for this handler
* @note This function is not thread safe and should be called before any logging to this handler happens
* @param format_pattern format pattern see PatternFormatter
* @param timestamp_format defaults to "%H:%M:%S.%Qns"
* @param timezone defaults to PatternFormatter::Timezone::LocalTime
Expand Down
5 changes: 2 additions & 3 deletions quill/src/detail/backend/StringFromTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,12 @@ std::string const& StringFromTime::format_timestamp(time_t timestamp)
_pre_formatted_ts.clear();
_cached_indexes.clear();

// Now populate a pre formatted string for the next rec
// Now populate a pre-formatted string for the next rec
_populate_pre_formatted_string_and_cached_indexes(timestamp);

if (_time_zone == Timezone::LocalTime)
{
// Update the timestamp to point to the next hour, here we can just add 3600 as the _next_hour_timestamp was already rounded to point to sharp minutes before
_next_recalculation_timestamp = timestamp + 3600;
_next_recalculation_timestamp = next_hour_timestamp(timestamp);
}
else if (_time_zone == Timezone::GmtTime)
{
Expand Down
4 changes: 2 additions & 2 deletions quill/test/QuillLogTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ TEST_CASE("log_from_const_function")
// log again for class b
log_test_class const log_test_class_b{filename};
log_test_class_b.use_logger_const();
}

quill::flush();
quill::flush();
}

// Read file and check
std::vector<std::string> const file_contents = quill::testing::file_contents(filename);
Expand Down

0 comments on commit ba554dd

Please sign in to comment.