-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add example and CustomLogger #1
base: master
Are you sure you want to change the base?
Conversation
Please change the following:
|
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.
Please use snake_case
instead of camelCase
. E.g. with_field
instead of WithField
.
logfmt.cpp
Outdated
|
||
std::string logfmt::Entry::casting(std::string key, std::any val) //casting the value in map into string | ||
{ | ||
std::string custom_string; |
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.
Please refactor this function to multiple smaller function. Also, maybe it's better to use switch
instead of if
?
Maybe this would work:
std::string logfmt::Entry::casting(std::string key, std::any val) {
std::string custom_string;
if (JSON) {
custom_string = cast_json(key, value);
} else {
custom_string = cast_key_value(key, value);
}
return custom_string;
}
std::string logfmt::Entry::cast_json(std::string key, std::any val) {
switch (val.type()) {
case typeid(char):
...
}
}
logs/basic-log.txt
Outdated
@@ -0,0 +1,48 @@ | |||
[2018-08-07 17:18:01.153] [test] [info] INFO of WALRUS and its total animal = "walrus" total = 100 |
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.
Remove this file and add logs/
to .gitignore
Add
After that, run clang-format to reformat your code style. |
About using switch, trying to change it into switch statement but I think |
Updated. Please check the new commit. |
I saw a lot of duplication in |
.clang-format
Outdated
--- | ||
Language: Cpp | ||
BasedOnStyle: Google | ||
AccessModifierOffset: -1 |
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.
Have you confirm that the clang-format works? I still saw a lot of style inconsistency across the codes. To be safe, start with the first to line without any modification.
Language: Cpp
BasedOnStyle: Google
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.
Where is the duplication of cast_default and cast_JSON? I think it's only called in process_key function.
Tried it again with clang and nothing change this time so i think it's working, i try it with "clang-format -style=Google logfmt.cpp -i" and also clang-format in atom packages.
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 codes inside cast_default and cast_json. The part that contains type casting.
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.
Updated. Please review the new pull request.
Adding example.cpp and CustomLogger.cpp , to compile use "g++ example.cpp CustomLogger.cpp -o example -Wall -Wextra -pedantic -std=c++17 -pthread -Ispdlog_lib -fmax-errors=1 -O3 -march=native"