Skip to content
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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Carbohz
Copy link

@Carbohz Carbohz commented Feb 26, 2023

No description provided.

@github-actions
Copy link

github-actions bot commented Feb 26, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@Carbohz
Copy link
Author

Carbohz commented Feb 26, 2023

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=ru.

1 similar comment
@ProgrammingEnjoyerrr
Copy link

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=ru.

@Carbohz
Copy link
Author

Carbohz commented Feb 26, 2023

recheck

@Carbohz
Copy link
Author

Carbohz commented Feb 27, 2023

Related to the #180

Copy link
Member

@apolukhin apolukhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good start!

core/src/logging/format.cpp Outdated Show resolved Hide resolved
core/src/logging/log_json_test.cpp Show resolved Hide resolved
core/src/logging/spdlog_helpers.cpp Outdated Show resolved Hide resolved
@Carbohz Carbohz requested a review from segoon as a code owner March 4, 2023 14:16
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));
Copy link
Member

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"]);

Copy link
Author

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(.

Copy link
Member

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants