hardcore-os / naruto Goto Github PK
View Code? Open in Web Editor NEW高性能的c++日志库
License: MIT License
高性能的c++日志库
License: MIT License
测试代码如下:
int main() {
hardcode::naruto::LogConfig log_config;
hardcode::naruto::Logger::setGlobalConfig(log_config);
hardcode::naruto::Logger::getLogger()->addAppender(
"asyncfile", hardcode::naruto::LogAppenderInterface::Ptr(new hardcode::naruto::AsyncFileAppender("./lg/")));
const int32_t count = 10;
std::string tmp("testssss");
auto start = std::chrono::system_clock::now();
for (int32_t index = 0; index < count; ++index) {
hardcode::naruto::Logger::getLogger()->fatal("%d hello world, %s\n", index, tmp.c_str()); //ERROR!!!
}
auto end = std::chrono::system_clock::now();
auto duration =
std::chrono::duration_caststd::chrono::microseconds(end - start);
std::cout << count << "次运行耗时" << duration.count() << "us" << std::endl;
return 0;
}
我这边测试在 hardcode::naruto::Logger::getLogger()->fatal("%d hello world, %s\n", index, tmp.c_str()); 地方出现崩溃问题。堆栈如下:
Thread 1 "testMain" received signal SIGSEGV, Segmentation fault.
__strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:120
120 ../sysdeps/x86_64/multiarch/../strlen.S: No such file or directory.
(gdb) bt
#0 __strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:120
#1 0x00007ffffe88d4a3 in _IO_vfprintf_internal (s=s@entry=0x7ffffffedd40, format=format@entry=0x800f587 "%d hello world, %s\n",
ap=ap@entry=0x7ffffffee020) at vfprintf.c:1643
#2 0x00007ffffe8b88b0 in _IO_vsnprintf (string=0x842c470 "0 hello world, ", maxlen=,
format=0x800f587 "%d hello world, %s\n", args=0x7ffffffee020) at vsnprintf.c:114
#3 0x00000000080092aa in hardcode::naruto::Logger::writeLog (this=0x842ae70, log_level=hardcode::naruto::LogLevel::FATAL,
file_name=0x800f8b0 "../log.cpp", function_name=0x800f900 <hardcode::naruto::Logger::fatal(char const*, ...)::FUNCTION> "fatal",
line_num=83, fmt=0x800f587 "%d hello world, %s\n", ap=0x7ffffffee020) at ../log.cpp:117
#4 0x0000000008008f46 in hardcode::naruto::Logger::fatal (this=0x842ae70, format=0x800f587 "%d hello world, %s\n") at ../log.cpp:83
#5 0x0000000008003e49 in main () at ./naruto_test.cpp:17
(gdb)
这个问题个人能力不足无法定位和解决。有大佬可以帮忙看一下嘛?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.