-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (35 loc) · 1.3 KB
/
main.cpp
File metadata and controls
41 lines (35 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Use this file to demo or practive Logger usage and implementation.
* Please contribute to this project by raising pull request at
* https://github.com/DHANUSH-web/cpp-logger.git/pulls
*
* Developer - Dhanush H V <dhanushhv75@gmail.com>
* Website - https://dhanushhv.vercel.app
*/
#include "logger.h"
#include <filesystem>
// Handle file system for specific platform
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
int main() {
const std::string name = "main";
const std::string root_dir = std::string(getcwd(nullptr, 100)) + std::string("/logs"); // Insert absolute path of log file root
const std::string log_file = "test_logger.log"; // Insert log file name
const bool debug = true;
// Initiated logger instance
auto logger = Logger(name, root_dir, log_file, debug);
// add some logs
logger.log("Debug log!", LOGGER::LEVEL::DEBUG);
logger.log("Info log!", LOGGER::LEVEL::INFO);
logger.log("Warning log!", LOGGER::LEVEL::WARNING);
logger.log("Error log!", LOGGER::LEVEL::ERROR);
logger.log("Fatal log!", LOGGER::LEVEL::FATAL);
logger.log("Unknown log!", LOGGER::LEVEL::UNKNOWN);
logger.log("Message log!", LOGGER::LEVEL::MESSAGE);
// close logger
logger.exit_logger();
return 0;
}