Code Monkey home page Code Monkey logo

Comments (9)

tt4g avatar tt4g commented on August 26, 2024

Logging macros such as SPDLOG_LOGGER_DEBUG are used to remove logging statements that are not needed in the product: https://github.com/gabime/spdlog/wiki/0.-FAQ#how-to-remove-all-debug-statements-at-compile-time-

If you want to enable log output according to the log level required by the user, use the log level filter API such as spdlog::set_level() to set the log level to be logged at runtime.

from spdlog.

germandiagogomez avatar germandiagogomez commented on August 26, 2024

Logging macros such as SPDLOG_LOGGER_DEBUG are used to remove logging statements that are not needed in the product: https://github.com/gabime/spdlog/wiki/0.-FAQ#how-to-remove-all-debug-statements-at-compile-time-
Yes. I am aware of that.
If you want to enable log output according to the log level required by the user, use the log level filter API such as spdlog::set_level() to set the log level to be logged at runtime.

That will make all paramterws in the log calls I use evaluated even if the log level is disabled. That is why I am trying to either disable it totally (best solution) or lazy-evaluate log parameters in some way because an empty call will be done. This is server-side software so I would like to remove every piece of overhead as much as possible.

from spdlog.

tt4g avatar tt4g commented on August 26, 2024

I would like to remove every piece of overhead as much as possible.

Does overhead mean matchToken.toString()?
If so, a user-defined type formatter in the fmt library (https://fmt.dev/10.2.0/api.html#formatting-user-defined-types) can lazy the evaluation of matchToken.toString() after filtering by log level.

from spdlog.

gabime avatar gabime commented on August 26, 2024

These macros do exactly what you need. Not sure why get multiple definitions error.

from spdlog.

germandiagogomez avatar germandiagogomez commented on August 26, 2024

These macros do exactly what you need. Not sure why get multiple definitions error.

Please see above. I define the active level and I get multiple definitions. I use the pre-compiled (not the header-only) library, so probably it is the source of the problem?

from spdlog.

gabime avatar gabime commented on August 26, 2024

I get multiple definitions

Shouldn't happen. Something is wrong with your build. For example see this define in the tests.

from spdlog.

tt4g avatar tt4g commented on August 26, 2024

If the precompiled headers are generated by CMake, it may be due to CMake's ability to record the arguments of the cmake command.

For example, if cmake -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE is defined when building a precompiled header, -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE is recorded and -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE is automatically added to the argument when the precompiled header is used.

from spdlog.

germandiagogomez avatar germandiagogomez commented on August 26, 2024

My setup is consuming a library (Not header-only, but precompiled outside of the project). I consume it via pkg config and in ky build system for my libs I link spdlog precompiled and try to change the active log level macro.

Probably that is where the mismatch kight come from: precompiled lib has the active log level as something and my lib when using it redefines it?

from spdlog.

tt4g avatar tt4g commented on August 26, 2024

Since the macro redefinition warning message is printed, we should assume that build tools is defining the macro.
Have you checked to see if your build tool has the ability to automatically define macros?

from spdlog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.