-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogger.cpp
More file actions
52 lines (45 loc) · 1.21 KB
/
logger.cpp
File metadata and controls
52 lines (45 loc) · 1.21 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
42
43
44
45
46
47
48
49
50
51
52
//
// Created by root on 2020/6/8.
//
#include <iostream>
#include "spdlog/sinks/stdout_color_sinks.h"
#include "logger.h"
namespace HC
{
#define MAX_BUF_SIZE 2048
HCLogger* HCLogger::intance_ = nullptr;
const std::string myLoggerName = "HCLogger";
HCLogger::HCLogger()
{
// m_logger = spdlog::get(myLoggerName);
// Create color multi threaded logger.
auto console = spdlog::stdout_color_mt("console");
// or for stderr:
// auto console = spdlog::stderr_color_mt("error-logger");
// Customize msg format for all loggers
spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [thread %t] %v");
spdlog::info("This an info message with custom format");
// spdlog::set_pattern("%+"); // back to default format
spdlog::set_level(spdlog::level::trace);
}
HCLogger::~HCLogger()
{
if (intance_)
{
delete intance_;
intance_ = nullptr;
}
}
HCLogger* HCLogger::getInstance()
{
if (intance_ == nullptr)
{
intance_ = new HCLogger();
}
return intance_;
}
std::string HCLogger::loggerName()
{
return myLoggerName;
}
}