GithubHelp home page GithubHelp logo

Comments (2)

guangie88 avatar guangie88 commented on September 20, 2024 1

So I have investigated the issue, this is due to the changes made to spdlog sinks in particular since v1.0.0 see here, where sinks are now allowed to have their own formats.

The code that causes this is here: https://github.com/gabime/spdlog/blob/v1.0.0/include/spdlog/details/logger_impl.h#L40-L51, so now setting format on the logger basically just forwards and sets all its associated sinks with the given format, which consequently also means that the ordering of setting the format on the loggers actually now matters if they share some common sinks, which is the case in your given TOML example. I must say having both loggers and sinks to be allowed setting format makes the situation pretty complicated, in particular this makes the config even less declarative.

Unfortunately currently spdlog_setup doesn't support setting format on the sinks, which would likely become the recommended practice when it gets implemented. For now, to get back the behavior, you would have to set different sinks on each logger as shown below:

[[sink]]
name = "console_simple"
type = "stdout_sink_mt"

[[sink]]
name = "console_complex"
type = "stdout_sink_mt"

[[pattern]]
name = "complex"
value = "[%Y-%m-%d %T,%e %n] <%l> %v"

[[pattern]]
name = "simple"
value = "%n %v"

[[logger]]
name = "other"
sinks = ["console_simple"]
level = "debug"
pattern = "simple"

[[logger]]
name = "root"
sinks = ["console_complex"]
level = "trace"
pattern = "complex"

Hope this clarifies the issue.

from spdlog_setup.

guangie88 avatar guangie88 commented on September 20, 2024

Hi sorry for the late reply, I have tested the above and this is indeed true.

The last tag that works is v0.3.0-alpha.1, but this requires a pre-v1.x spdlog set-up. If you prefer to get a working logging output as priority and do not require spdlog v1.x, then the easiest way to do so is to:

git checkout v0.3.0-alpha
git submodule init && git submodule update --recursive
mkdir -p build
cd build
cmake ..
cmake --build .
sudo cmake --build . --target install

This will give you spdlog_setup v0.3.0-alpha.1 + spdlog v0.16.3 in /usr/local/include (be careful this might overwrite existing spdlog files), which I have tested to be working with your given example.

Meanwhile I will investigate if I have committed a bug (or might be upstream) at the current tag. Thanks for reporting the find!

from spdlog_setup.

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.