-
Notifications
You must be signed in to change notification settings - Fork 14
/
LoggingModule.hpp
38 lines (33 loc) · 963 Bytes
/
LoggingModule.hpp
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
#pragma once
#include "../../Logging/Logger.hpp"
#include "../ModuleBase.hpp"
namespace cpv {
/**
* Module used to provide logger
*
* By default, it uses console logger with Notice level,
* you can set custom logger by using custom initialize function:
* ```
* application.add<LoggingModule>(auto& module) {
* module.setLogger(Logger::createConsole(LogLevel::Info));
* });
* ```
* and get logger instance from the container:
* ```
* auto logger = container.get<seastar::shared_ptr<Logger>>();
* ```
*
* The lifetime of logger instance is persistent.
*/
class LoggingModule : public ModuleBase {
public:
/** Set custom logger */
void setLogger(const seastar::shared_ptr<Logger>& logger);
/** Do some work for given application state */
seastar::future<> handle(Container& container, ApplicationState state) override;
/** Constructor */
LoggingModule();
private:
seastar::shared_ptr<Logger> logger_;
};
}