Questions tagged [spdlog]

Very fast, header only, C++ logging library.

GitHub Project

Very fast, header only, C++ logging library.

118 questions
1
vote
0 answers

Mismatch between C++17 and C++20, const char* no longer a constant expression

I have a project where I use the spdlog library. My header file looks like this: #pragma once #include #include #include namespace vtek { void initialize_logging(const InitInfo* info); void…
alexpanter
  • 1,222
  • 10
  • 25
1
vote
0 answers

How do I share logger object between source files without segmentation fault?

I'm using spdlog and trying to create a logger object to be shared between multiple source files. However, whenever I use the built in spdlog::get() function it results in a segmentation fault error. foo.cpp #include "bar.h" #include…
ewaddicor
  • 29
  • 2
1
vote
2 answers

How to configure spdlog logger used in a pybind11 module

I'm using spdlog in various C++ libraries for which Python bindings are created with pybind11. Now I'm wondering if there is a nice way how I can configure these loggers (mostly the level and format) from the Python side. Currently I am creating a…
luator
  • 4,769
  • 3
  • 30
  • 51
1
vote
1 answer

Promtail keep last log bufferised and don't give it to Loki

I have a pretty simple application which send tcp log to promtail. (So promtail doesn't gaver data from file) The problem is that the last log sent to protail isn't stored in loki until another log comes. Let's say that I logged "foo", I'll see…
lou lou
  • 11
  • 2
1
vote
1 answer

Spdlog: Only write to file if there is an error

At the moment I am combining a file sink with a console sink. (see bellow) std::vector sinks; sinks.push_back(std::make_shared()); …
lukan
  • 31
  • 6
1
vote
1 answer

How to print filename and function name using spdlog?

Following spdlog documentation I was able to modify the print pattern #include "spdlog/spdlog.h" #include "spdlog/sinks/daily_file_sink.h" int main() { spdlog::set_pattern("%H:%M:%S.%e %t %s %! %v"); auto logger =…
KcFnMi
  • 5,516
  • 10
  • 62
  • 136
1
vote
0 answers

Two sinks logger as default logger not working

I'm trying to combine two sinks: auto console_sink = std::make_shared(); console_sink->set_level(spdlog::level::warn); console_sink->set_pattern("[multi_sink_example] [%^%l%$] %v"); auto…
Rachel91
  • 59
  • 4
1
vote
1 answer

Ignore 3rd party headers from clang-tidy in cmake

How can I avoid clang tidy warnings on my external library I am downloading using FetchContent. Is their an easy way to treat these as system libraries. I have done this in the past with my own header lib that I wanted to ignore…
user2020
  • 217
  • 2
  • 12
1
vote
1 answer

I use spdlog in my c++ project normally, i meet strange errors, and i don`t know why this happen

When compile my project, i got there errors, i have no ideas about this error In file included from…
mandi
  • 11
  • 1
1
vote
1 answer

Get Colorized spdlog output with qt_sinks

Ok so I hooked up the QTextEdit with spdlog. But how to get the colorized output from spdlog/fmt to show in the QTextEdit? Am I doomed to implement my own message handler for that to happen? Or is there a slicker way?
anlowho
  • 11
  • 1
1
vote
0 answers

Can't compile Format.h 'fmt::v8::detail::do_throw' not found? c++14

The code was compiling fine until the compiler shown that error. It's the second time that it happened to me, I didn't solved yet, I just copied a last version of my project when it happened for the first time. On both, it just appeared doing…
1
vote
1 answer

query the spdlog logger name

say we build our spdlog object as the following? logger = std::make_shared("some name", sink_list.begin(), sink_list.end()); Is there a method such as logger->get_name() or anything else that would return "some name"
Alejandro
  • 879
  • 11
  • 27
1
vote
0 answers

Spdlog - how to manually clear a file with basic_file_sink_mt

Spdlog appears to have a trancute upon construction of basic_file_sink_mt, but other then that there appears to be no method that can be called to clear the file. My current workaround is to reconstruct the basic_file_sink_mt object so that trancute…
Tom
  • 1,235
  • 9
  • 22
1
vote
1 answer

How I can paint a text background with spdlog?

I did a test with the {fmt} and was super easy to change background color, but I can't get the same with spdlog. I can get the same result with spdlog, but is a weird code fmt::print( bg( fmt::terminal_color::yellow ) | fg(…
1
vote
0 answers

std::string_view rvalue from macro not a constant expression when building on aarch64 using GCC

I have an issue building my library for aarch64. Note that this code builds and runs fine when building for x86. I have a macro: #define LOG_WARN(logger, message, ...) if (logger) { logger->Warn(message, __VA_ARGS__); } I use it in the code like…
George Pippos
  • 81
  • 1
  • 1
  • 5