File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # AsyncLogger
2+
3+ ## How to use
4+
5+ Very simple example application showing how to implement it.
6+
7+ main.cpp
8+ ``` cpp
9+ #include " Logger.hpp"
10+ #include < filesystem>
11+ #include < iostream>
12+
13+ using namespace base ;
14+
15+ void COUT_LOG (LogMessagePtr msg)
16+ {
17+ const auto& location = msg->Location();
18+ const auto file = std::filesystem::path(msg->Location().file_name()).filename().string();
19+
20+ std::cout << "[" << file << ":" << location.line() << "] " << msg->Message();
21+ }
22+
23+ int main()
24+ {
25+ Logger::Init();
26+ Logger::AddSink(COUT_LOG);
27+
28+ LOG(INFO) << "Test " << 1 << 2 << 3 << " some float (" << 3.5f << ")";
29+
30+ Logger::Destroy();
31+
32+ return 0;
33+ }
34+ ```
35+ Logs the following output:
36+ ```
37+ [ main.cpp:20] Test 123 some float (3.5)
38+ ```
39+
40+ CMakeLists.txt
41+ ```cmake
42+ cmake_minimum_required(VERSION 3.20)
43+ set(CMAKE_CXX_STANDARD 20 GLOBAL)
44+
45+ project(my_app LANGUAGES CXX VERSION 0.0.1)
46+
47+ add_subdirectory(AsyncLogger)
48+ add_executable(${PROJECT_NAME} src/main.cpp)
49+ target_link_libraries(${PROJECT_NAME} AsyncLogger)
50+ ```
51+
52+ CMakeLists.txt using FetchContent
53+ ``` cmake
54+ cmake_minimum_required(VERSION 3.20)
55+ set(CMAKE_CXX_STANDARD 20 GLOBAL)
56+
57+ project(my_app LANGUAGES CXX VERSION 0.0.1)
58+
59+ include(FetchContent)
60+ FetchContent_Declare(
61+ AsyncLogger
62+ GIT_REPOSITORY https://github.com/Yimura/AsyncLogger.git
63+ GIT_TAG master
64+ GIT_PROGRESS TRUE
65+ )
66+ FetchContent_MakeAvailable(AsyncLogger)
67+
68+ add_executable(${PROJECT_NAME} src/main.cpp)
69+ target_link_libraries(${PROJECT_NAME} AsyncLogger)
70+ ```
You can’t perform that action at this time.
0 commit comments