summaryrefslogtreecommitdiff
path: root/project2/common/loggerFactory.h
blob: 1c6033b150429870bc3318f46f0ccc31d3e2ab64 (plain)
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
#ifndef LOGGERFACTORY_H
#define LOGGERFACTORY_H

#include <factory.h>
#include "lifeCycle.h"
#include "intrusivePtrBase.h"
#include "logger.h"
#include <visibility.h>

/// Base class for classes providing a logging facility
class DLL_PUBLIC LogDriverBase : public virtual IntrusivePtrBase {
	public:
		LogDriverBase();
		virtual ~LogDriverBase();

		virtual void message(int priority, const char * msg) const = 0;
};

class DLL_PUBLIC LogDriverFactory : public AdHoc::Factory<LogDriverBase> {
	public:
		virtual int loggerLevel() const = 0;
};

template<typename LoggerType>
class LogDriverFactoryImpl : public LogDriverFactory, public LifeCycle {
	public:
		LogDriverFactoryImpl();

		virtual void onConfigLoad() override;
		inline LoggerType * create() const override;
		int loggerLevel() const override;

		const int & level;

	protected:
		mutable boost::intrusive_ptr<LoggerType> instance;
};

#endif