Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kezhengjie/cpplog
https://github.com/kezhengjie/cpplog
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kezhengjie/cpplog
- Owner: kezhengjie
- License: mit
- Created: 2021-06-15T07:45:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-28T02:40:26.000Z (about 3 years ago)
- Last Synced: 2024-12-25T03:22:15.314Z (10 days ago)
- Language: C++
- Size: 389 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cpplog
## A simple async log written in c++.Integrated with MsgQueue.
### Introduction
A simple log library,controlled with MsgQueue.### Usage
```
#include "log.h"
#includeint main(int argc,char** argv)
{
//Assume current date is 2021-08-10.
// LogName returns a LoggerShell instance.
logutil::LogName("test").Print("Print() will both print to stdout and log to debug 2021-08-10.log file");
logutil::LogName("test").Log("Log() will only log to debug 2021-08-10.log file without print to stdout");
// GetLogger returns a pointer to Logger which is managed by LogManager.
logutil::GetLogger("debug")->Print("Print() will both print to stdout and log to debug 2021-08-10.log file");
logutil::GetLogger("debug")->Log("Log() will only log to debug 2021-08-10.log file without print to stdout");std::this_thread::sleep_for(std::chrono::seconds(10));
// Logger could also be construct without managing by LogManager.
// remember this is thread not safe.
auto l = new logutil::Logger("test");
l->Print("something");
l->Log("something");
delete l;}
```
### Document
logutil::Name("log") is thread safe,dispatched by a msg queue in LogManager.Check log.cpp for more detail.
But remember logutil::Logger::Log is not thread safe;