This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
nettrans/util/net_pub.h

36 lines
670 B
C
Raw Normal View History

2024-04-16 21:34:06 +08:00
#ifndef NET_PUB_HPP
#define NET_PUB_HPP
#include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/sinks/stdout_color_sinks.h>
2024-04-16 21:34:06 +08:00
#include <spdlog/spdlog.h>
#include <memory>
#include <mutex>
class noncopyable
{
protected:
noncopyable() = default;
noncopyable(const noncopyable&) = delete;
noncopyable& operator=(const noncopyable&) = delete;
};
typedef std::shared_ptr<spdlog::logger> Log_t;
class CLogger : public noncopyable
{
2024-04-16 21:34:06 +08:00
public:
static Log_t getLogger();
private:
void init();
using CPtrLogger = std::shared_ptr<CLogger>;
2024-04-16 21:34:06 +08:00
private:
static CPtrLogger logger_;
static std::mutex mutex_;
static Log_t log_;
2024-04-16 21:34:06 +08:00
};
#endif