Simple multipurpose logger
Fork of LogIt by
README.md@5:e16468c1160f, 2016-12-14 (annotated)
- Committer:
- Nico De Witte
- Date:
- Wed Dec 14 19:03:57 2016 +0100
- Revision:
- 5:e16468c1160f
- Child:
- 7:eb101b1726a5
Add LICENSE and README.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nico De Witte |
5:e16468c1160f | 1 | # Mbed LogIt |
Nico De Witte |
5:e16468c1160f | 2 | |
Nico De Witte |
5:e16468c1160f | 3 | Logger library that is build based on the LoggerInterface library that follows |
Nico De Witte |
5:e16468c1160f | 4 | the PSR-3 logger standard. |
Nico De Witte |
5:e16468c1160f | 5 | |
Nico De Witte |
5:e16468c1160f | 6 | This library provides an abstract class logable to make your classes easily Logger |
Nico De Witte |
5:e16468c1160f | 7 | aware. |
Nico De Witte |
5:e16468c1160f | 8 | |
Nico De Witte |
5:e16468c1160f | 9 | Besides that the LogIt library also has a SerialLogger implementation and a NullLogger |
Nico De Witte |
5:e16468c1160f | 10 | for production applications where no logging should be done. |
Nico De Witte |
5:e16468c1160f | 11 | |
Nico De Witte |
5:e16468c1160f | 12 | NullLogger is used as a default when making your classes Logger aware. It is implemented |
Nico De Witte |
5:e16468c1160f | 13 | using the Singleton pattern to avoid waste of resources. |
Nico De Witte |
5:e16468c1160f | 14 | |
Nico De Witte |
5:e16468c1160f | 15 | ## Using LogIt |
Nico De Witte |
5:e16468c1160f | 16 | |
Nico De Witte |
5:e16468c1160f | 17 | First make your class inherit from Logable as such |
Nico De Witte |
5:e16468c1160f | 18 | |
Nico De Witte |
5:e16468c1160f | 19 | ```C++ |
Nico De Witte |
5:e16468c1160f | 20 | class Router : public LogIt::Logable { |
Nico De Witte |
5:e16468c1160f | 21 | //... |
Nico De Witte |
5:e16468c1160f | 22 | }; |
Nico De Witte |
5:e16468c1160f | 23 | ``` |
Nico De Witte |
5:e16468c1160f | 24 | |
Nico De Witte |
5:e16468c1160f | 25 | Now you can use the `set_logger()` method to inject a logger into the class |
Nico De Witte |
5:e16468c1160f | 26 | or you can provide it as an optional argument to your constructors as shown below: |
Nico De Witte |
5:e16468c1160f | 27 | |
Nico De Witte |
5:e16468c1160f | 28 | ```C++ |
Nico De Witte |
5:e16468c1160f | 29 | Router::Router(int address, Log::LoggerInterface * logger = 0) { |
Nico De Witte |
5:e16468c1160f | 30 | set_logger(logger); |
Nico De Witte |
5:e16468c1160f | 31 | logger->info("Setting up the router"); |
Nico De Witte |
5:e16468c1160f | 32 | //... |
Nico De Witte |
5:e16468c1160f | 33 | } |
Nico De Witte |
5:e16468c1160f | 34 | ``` |
Nico De Witte |
5:e16468c1160f | 35 | |
Nico De Witte |
5:e16468c1160f | 36 | ## Dependencies |
Nico De Witte |
5:e16468c1160f | 37 | |
Nico De Witte |
5:e16468c1160f | 38 | This library currently only depends on the LoggerInterface itself which can be found at |
Nico De Witte |
5:e16468c1160f | 39 | [https://developer.mbed.org/users/dwini/code/LoggerInterface/](https://developer.mbed.org/users/dwini/code/LoggerInterface/) |