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

Make log macros into expressions #23

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

syyyr
Copy link
Contributor

@syyyr syyyr commented Jun 13, 2024

No description provided.

#define nCWarning(topic) for(bool necrolog__en__ = NecroLog::shouldLog(NecroLog::Level::Warning, NecroLog::LogContext(__FILE__, __LINE__, topic)); necrolog__en__; necrolog__en__ = false) NecroLog::create(NecroLog::Level::Warning, NecroLog::LogContext(__FILE__, __LINE__, topic))
#define nCError(topic) for(bool necrolog__en__ = NecroLog::shouldLog(NecroLog::Level::Error, NecroLog::LogContext(__FILE__, __LINE__, topic)); necrolog__en__; necrolog__en__ = false) NecroLog::create(NecroLog::Level::Error, NecroLog::LogContext(__FILE__, __LINE__, topic))

#define NECROLOG_IMPL_LOG_MACRO(level, topic) !NecroLog::shouldLog(NecroLog::Level::level, NecroLog::LogContext(__FILE__, __LINE__, topic)) ? NecroLog::create(NecroLog::Level::level, NecroLog::LogContext(__FILE__, __LINE__, topic)) : NecroLog::create(NecroLog::Level::level, NecroLog::LogContext(__FILE__, __LINE__, topic))
Copy link
Owner

Choose a reason for hiding this comment

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

Both branches are apparently the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's how the macro works. You put a << after it, and if "should Log" is true, it'lll og, otherwise not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it'd be better to put a comment explaining this in the code

Copy link
Owner

@fvacek fvacek Jan 11, 2025

Choose a reason for hiding this comment

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

Wouldn't it produce empty log line in case that shouldLog() == false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, maybe, I haven't tested it.

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.

2 participants