2025年spdlog开源库使用

spdlog开源库使用spdlog spdlog 是一个非常简单快速的日志库 到现在为止仅仅简单尝试了一下 使用体验比较满意 这里推荐一下 下面是开源库的源地址 源地址 安装 git clone https github com gabime spdlog git cd spdlog amp amp mkdir build amp amp cd build cmake amp amp make j 安装也非常简单

spdlog

spdlog是一个非常简单快速的日志库。到现在为止仅仅简单尝试了一下,使用体验比较满意。这里推荐一下。下面是开源库的源地址:源地址

安装

$ git clone https://github.com/gabime/spdlog.git
$ cd spdlog && mkdir build && cd build
$ cmake .. && make -j

安装也非常简单,只有三条命令。

支持的系统

Linux, FreeBSD, OpenBSD, Solaris, AIX

Windows (msvc 2013+, cygwin)

macOS (clang 3.5+)

Android

使用方法

我的运行环境:Liunx Ubuntu20.几版本。给忘了。
编译好之后,进入文件夹,你会发现有一个include文件夹,进入这个文件夹,有一个spdlog文件夹。将这个文件夹复制到/usr/include文件夹里。
接下来,你可以在与spdlog同一级目录中创建C++文件输入如下代码测试它。

#include "spdlog/spdlog.h"

int main()
{

spdlog::info("Welcome to spdlog!");
spdlog::error("Some error message with arg: {}", 1);

spdlog::warn("Easy padding in numbers like {:08d}", 12);
spdlog::critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
spdlog::info("Support for floats {:03.2f}", 1.23456);
spdlog::info("Positional args are {1} {0}..", "too", "supported");
spdlog::info("{:<30}", "left aligned");

spdlog::set_level(spdlog::level::debug); // Set global log level to debug
spdlog::debug("This message should be displayed..");

// change log pattern
spdlog::set_pattern("[%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v");

// Compile time log levels
// define SPDLOG_ACTIVE_LEVEL to desired level
SPDLOG_TRACE("Some trace message with param {}", 42);
SPDLOG_DEBUG("Some debug message");
}

未完待续。。。

(小声测试下: α i = ( X T X ) − 1 X y \alpha_i=(X^TX)^{-1}Xy αi​=(XTX)−1Xy)

编程小号
上一篇 2025-01-16 12:11
下一篇 2025-01-24 09:30

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/147962.html