-
-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for CROW_USE_LOCALTIMEZONE
for using localtime in logs
#368
Conversation
As mentioned here, I think it's best if GMT is default and there's a macro to change it to local time. I just don't know what happened to the work I was supposed to do.. |
58245ed
to
2c0291b
Compare
Updated the PR with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The time in http_server.h
must be GMT and not local to the server as per HTTP, please revert the last commit.
CROW_USE_LOCALTIMEZONE
for using localtime in response/logs
CROW_USE_LOCALTIMEZONE
for using localtime in response/logsCROW_USE_LOCALTIMEZONE
for using localtime in logs
Done. Sorry, wasn't aware of this. |
727808e
to
ce432db
Compare
No worries, and thanks a lot for taking the time to work on improving Crow! |
--- include/crow/logging.h (before formatting)
+++ include/crow/logging.h (after formatting)
@@ -72,17 +72,17 @@
tm my_tm;
#if defined(_MSC_VER) || defined(__MINGW32__)
- #ifdef CROW_USE_LOCALTIMEZONE
+#ifdef CROW_USE_LOCALTIMEZONE
localtime_s(&my_tm, &t);
- #else
+#else
gmtime_s(&my_tm, &t);
- #endif
+#endif
#else
- #ifdef CROW_USE_LOCALTIMEZONE
+#ifdef CROW_USE_LOCALTIMEZONE
localtime_r(&t, &my_tm);
- #else
+#else
gmtime_r(&t, &my_tm);
- #endif
+#endif
#endif
size_t sz = strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", &my_tm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the only thing left is formatting.
define CROW_USE_LOCALTIMEZONE macro for explict optin for localtimezone in logs
6e40d28
to
77e68e4
Compare
Had already fixed the formatting error reported by crow-clang-format. Hoping this time it will pass all the checks. |
@The-EDev Please check. Github CI reports that all check have passed |
Hi @The-EDev
This changes
gmtime_*
tolocaltime_*
to use local dates in the logs. Most other HTTP servers usually use local date time by default, hence changing this.Also wanted your views if this should be configurable or not using a
#ifdef
? What do you think?