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

Add SPDLOG_VERSION check support #2853

Merged
merged 1 commit into from
Aug 14, 2023
Merged

Add SPDLOG_VERSION check support #2853

merged 1 commit into from
Aug 14, 2023

Conversation

kegechen
Copy link
Contributor

@kegechen kegechen commented Aug 10, 2023

You can use SPDLOG_VERSION to select the latest spdlog features
where available while falling back to older implementations otherwise.
Using SPDLOG_TO_VERSION() for the value to compare with is recommended.
for Example:

 void sink_it_(const details::log_msg &msg) override
 {
 #if SPDLOG_VERSION < SPDLOG_TO_VERSION(1,4,0)
     fmt::memory_buffer formatted;
 #else
     memory_buf_t formatted;
 #endif
     sinks::base_sink<Mutex>::formatter_->format(msg, formatted);
     // bala bala...
 }

@gabime
Copy link
Owner

gabime commented Aug 11, 2023

Thanks. Since the macro by itself doesn't actually check anything, I think it should be named differently, perhaps SPDLOG_GET_VERSION(..) or similar.

@kegechen
Copy link
Contributor Author

kegechen commented Aug 12, 2023

Thanks. Since the macro by itself doesn't actually check anything, I think it should be named differently, perhaps SPDLOG_GET_VERSION(..) or similar.

https://doc.qt.io/qt-6/qtversionchecks-proxy.html#QT_VERSION_CHECK
that's how Qt is used, but what you say makes sense,I prefer SPDLOG_MAKE_VERSION

@kegechen kegechen changed the title Add SPDLOG_VERSION_CHECK to compare spdlog version Add SPDLOG_GET_VERSION to compare spdlog version Aug 12, 2023
@kegechen kegechen changed the title Add SPDLOG_GET_VERSION to compare spdlog version Add SPDLOG_VERSION check support Aug 12, 2023
@gabime
Copy link
Owner

gabime commented Aug 12, 2023

But now it might confuse users with the make tool :)
How about SPDLOG_TO_VERSION() ?

You can use SPDLOG_VERSION to select the latest spdlog features
where available while falling back to older implementations otherwise.
Using SPDLOG_TO_VERSION() for the value to compare with is recommended.
for Example:
```c++
 void sink_it_(const details::log_msg &msg) override
 {
 #if SPDLOG_VERSION < SPDLOG_TO_VERSION(1,4,0)
     fmt::memory_buffer formatted;
 #else
     memory_buf_t formatted;
 #endif
     sinks::base_sink<Mutex>::formatter_->format(msg, formatted);
     // bala bala...
 }
```
@kegechen
Copy link
Contributor Author

But now it might confuse users with the make tool :) How about SPDLOG_TO_VERSION() ?

done

@gabime gabime merged commit cedfeeb into gabime:v1.x Aug 14, 2023
9 checks passed
@gabime
Copy link
Owner

gabime commented Aug 14, 2023

Thanks @kegechen

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