-
Notifications
You must be signed in to change notification settings - Fork 275
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
feat core: add json logging format #256
base: develop
Are you sure you want to change the base?
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=ru. |
1 similar comment
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=ru. |
recheck |
Related to the #180 |
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.
Very good start!
EXPECT_NE(str.find("local:"), std::string::npos) << str; | ||
EXPECT_NE(str.find("local tag value"), std::string::npos) << str; | ||
|
||
ASSERT_NO_THROW(formats::json::FromString(str)); |
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.
When logging tags/spans with JSON each tag should become a separate key on the output.
Please add tests like:
auto json = formats::json::FromString(str);
EXPECT_EQ(json["frozen"].As<std::string>(), "frozen tag value");
EXPECT_EQ(json["tag"].As<std::string>(), "tag value");
EXPECT_EQ(json["local"].As<std::string>(), "local tag value");
EXPECT_TRUE(json["task_id"]);
EXPECT_TRUE(json["thread_id"]);
EXPECT_TRUE(json["module"]);
EXPECT_TRUE(json["level"]);
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.
I need a hint. How can/should I do this?
When I log with macros (say, LOG_INFO()
), it creates default stderr logger. Actual logging takes place in LogHelper
ctor, with help of methods Log*
, which in turn use Put(utils::encoding::kTskvPairsSeparator)
. Looks like I can't modify logic of logging, I have no access to logging format here, so I can't put quotes here(.
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.
Yes, unfortunately it would require quite a lot of refactoring. The Put(utils::encoding::kTskvPairsSeparator);
logic should be moved to the pimpl_, and replaced with something like pimpl->PutPairsSeparator();
No description provided.