Simple multipurpose logger

Fork of LogIt by Nico De Witte

Committer:
Nico De Witte
Date:
Thu Dec 15 19:29:05 2016 +0100
Revision:
6:17bc740828b8
Parent:
4:9c5143891c8a
Child:
7:eb101b1726a5
Make logger pointer in logable protected instead of public.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nico De Witte 4:9c5143891c8a 1 #pragma once
Nico De Witte 4:9c5143891c8a 2
Nico De Witte 4:9c5143891c8a 3 #include "null_logger.h"
Nico De Witte 4:9c5143891c8a 4
Nico De Witte 4:9c5143891c8a 5 // Allow your classes to easily log by implementing Logable
Nico De Witte 4:9c5143891c8a 6
Nico De Witte 4:9c5143891c8a 7 namespace LogIt {
Nico De Witte 4:9c5143891c8a 8
Nico De Witte 4:9c5143891c8a 9 class Logable
Nico De Witte 4:9c5143891c8a 10 {
Nico De Witte 6:17bc740828b8 11 protected:
Nico De Witte 4:9c5143891c8a 12 Log::LoggerInterface * logger;
Nico De Witte 4:9c5143891c8a 13
Nico De Witte 4:9c5143891c8a 14 public:
Nico De Witte 4:9c5143891c8a 15 Logable(void) {
Nico De Witte 4:9c5143891c8a 16 this->logger = NullLogger::get_instance();
Nico De Witte 4:9c5143891c8a 17 }
Nico De Witte 4:9c5143891c8a 18
Nico De Witte 4:9c5143891c8a 19 void set_logger(Log::LoggerInterface * logger = 0) {
Nico De Witte 4:9c5143891c8a 20 if (logger == 0) {
Nico De Witte 4:9c5143891c8a 21 this->logger = NullLogger::get_instance();
Nico De Witte 4:9c5143891c8a 22 } else {
Nico De Witte 4:9c5143891c8a 23 this->logger = logger;
Nico De Witte 4:9c5143891c8a 24 }
Nico De Witte 4:9c5143891c8a 25 }
Nico De Witte 4:9c5143891c8a 26 };
Nico De Witte 4:9c5143891c8a 27
Nico De Witte 4:9c5143891c8a 28 };