spdlog linux编译出错,spdlog「建议收藏」

spdlog linux编译出错,spdlog「建议收藏」#include#include”spdlog/spdlog.h”intmain(int,char*[]){namespacespd=spdlog;try{//consolelogger(multithreadedandwithcolor)autoconsole=spd::stdout_logger_mt(“console”,true);console-&gt…

大家好,又见面了,我是你们的朋友全栈君。

#include

#include “spdlog/spdlog.h”

int main(int, char* [])

{

namespace spd = spdlog;

try {

// console logger (multithreaded and with color)

auto console = spd::stdout_logger_mt(“console”, true);

console->info(“Welcome to spdlog!”) ;

console->info(“An info message example {}..”, 1);

console->info() << “Streams are supported too ” << 1;

//Formatting examples

console->info(“Easy padding in numbers like {:08d}”, 12);

console->info(“Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}”, 42);

console->info(“Support for floats {:03.2f}”, 1.23456);

console->info(“Positional args are {1} {0}..”, “too”, “supported”);

console->info(“{:<30}”, “left aligned”);

console->info(“{:>30}”, “right aligned”);

console->info(“{:^30}”, “centered”);

//

// Runtime log levels

//

spd::set_level(spd::level::info); //Set global log level to info

console->debug(“This message shold not be displayed!”);

console->set_level(spd::level::debug); // Set specific logger’s log level

console->debug(“Now it should..”);

//

// Create a file rotating logger with 5mb size max and 3 rotated files

//

auto file_logger = spd::rotating_logger_mt(“file_logger”, “logs/mylogfile”, 1048576 * 5, 3);

for (int i = 0; i < 10; ++i)

file_logger->info(“{} * {} equals {:>10}”, i, i, i * i);

//

// Create a daily logger – a new file is created every day on 2:30am

//

auto daily_logger = spd::daily_logger_mt(“daily_logger”, “logs/daily”, 2, 30);

//

// Customize msg format for all messages

//

spd::set_pattern(“*** [%H:%M:%S %z] [thread %t] %v ***”);

file_logger->info(“This is another message with custom format”);

spd::get(“console”)->info(“loggers can be retrieved from a global registry using the spdlog::get(logger_name) function”);

//

// Compile time debug or trace macros.

// Enabled #ifdef SPDLOG_DEBUG_ON or #ifdef SPDLOG_TRACE_ON

//

SPDLOG_TRACE(console, “Enabled only #ifdef SPDLOG_TRACE_ON..{} ,{}”, 1, 3.23);

SPDLOG_DEBUG(console, “Enabled only #ifdef SPDLOG_DEBUG_ON.. {} ,{}”, 1, 3.23);

//

// Asynchronous logging is very fast..

// Just call spdlog::set_async_mode(q_size) and all created loggers from now on will be asynchronous..

//

size_t q_size = 1048576; //queue size must be power of 2

spdlog::set_async_mode(q_size);

auto async_file = spd::daily_logger_st(“async_file_logger”, “logs/async_log.txt”);

async_file->info() << “This is async log..” << “Should be very fast!”;

//

// syslog example. linux only..

//

#ifdef __linux__

std::string ident = “spdlog-example”;

auto syslog_logger = spd::syslog_logger(“syslog”, ident, LOG_PID);

syslog_logger->warn(“This is warning that will end up in syslog. This is Linux only!”);

#endif

} catch (const spd::spdlog_ex& ex) {

std::cout << “Log failed: ” << ex.what() << std::endl;

}

}

// Example of user defined class with operator<<

class some_class {};

std::ostream& operator<

{

return os << “some_class”;

}

void custom_class_example()

{

some_class c;

spdlog::get(“console”)->info(“custom class with operator<<: c>

spdlog::get(“console”)->info() << “custom class with operator<<: c>

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/152285.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 微信公众号代理运营公司_多平台推广

    微信公众号代理运营公司_多平台推广最近公司项目需要切到微信服务号,但是公司内网环境需要开防火墙策略才能访问微信的开放API,实际上就是通过代理去访问。这里记录一下我通过代理去调用微信API遇到的坑及解决办法。

    2022年8月21日
    6
  • Kettle详细使用教程

    Kettle详细使用教程Kettle详细使用教程文章内容链接Kettle插入更新、自定义常量数据与删除、增加常量、增加序列Kettle插入更新、自定义常量数据与删除、增加常量、增加序列Kettle字段选择、剪切字符串、字符串替换、Concatfields、字符串操作Kettle字段选择、剪切字符串、字符串替换、Concatfields、字符串操作Kettle排序记录、去除重复记录、拆分字段、值映射、替换NULL值Kettle排序记录、去除重复记录、拆分字段、值映射、替换NULL值

    2022年5月10日
    54
  • GTest问题_itest.n z

    GTest问题_itest.n z1、cmkae出现”C:/Users/xxx/gcc/bin/gcc.exe”isnotabletocompileasimpletestprogram.问题在camke时添加-DCMAKE_C_COMPILER=gcc,-DCMAKE_C_COMPILER=gcc-DCMAKE_CXX_COMPILER=g++,-DCMAKE_MAKE_PROGRAM=make指定gcc、g++与make2、测试私有成员函数出现__xfer_bufptrsredeclaredwithdif

    2022年9月29日
    0
  • 树莓派Python教程:树莓派能做什么

    树莓派Python教程:树莓派能做什么第一课:什么是树莓派第二课:树莓派能做什么第三课:购买您的第一个树莓派第四课:如何安装树莓派系统1~4课如果看过C语言版本的,请掠过…第二课:树莓派能做什么树莓派能做什么,莫过于来看一遍树莓派的10个经典项目的视频了,我们先以图片的形式过一遍。NO.1树莓派实现VR注意这个人头上戴的是一个虚拟3D眼镜,他看到的场景是树莓派上安装的两个摄像头,这两个摄像头就相当于人的两只眼睛,把视频传到这个眼镜,然后通过openGl渲染一个场景出来,从而控制这个机器人去做一些事情,这个机器人就是用树莓派

    2022年5月1日
    57
  • 学会Zookeeper分布式锁–让面试官对你刮目相看「建议收藏」

    业务场景:电商系统,用户下单,需要生成唯一的订单编号,并且需要有业务意义,而不能使用UUID这种字符串,比如:年-月-日-时-分-秒-自增序号2019-11-11-23-59-59-001订单编号生成器工具类OrderCodeGenerator/***@description:订单编号生成器*@author:stwen_gan*@date:**/pu…

    2022年4月15日
    63
  • python 列表转字符串[通俗易懂]

    python 列表转字符串[通俗易懂]python中list转字符串命令:”.join(list)其中,引号中是字符之间的分割符,如“,”,“;”,“\t”等等如:list=[1,2,3,4,5]”.join(list)结果即为:12345′,’.join(list)结果即为:1,2,3,4,5

    2022年6月13日
    24

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号