LoggerInterface inspired by PHP PSR-3

Dependents:   LogIt

Committer:
Sille Van Landschoot
Date:
Sun Apr 02 13:18:33 2017 +0200
Revision:
6:015483427bd3
Parent:
4:96f938f3d98a
Parent:
3:f1457069237f
merge heads

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sille Van Landschoot 4:96f938f3d98a 1 #pragma once
sillevl 0:13d1767f0c98 2
sillevl 1:8ee5fd3c1bf1 3 namespace Log{
sillevl 0:13d1767f0c98 4
sillevl 0:13d1767f0c98 5 class LoggerInterface
sillevl 0:13d1767f0c98 6 {
sillevl 0:13d1767f0c98 7 public:
Sille Van Landschoot 3:f1457069237f 8
sillevl 1:8ee5fd3c1bf1 9 enum Level {EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG};
Sille Van Landschoot 3:f1457069237f 10
sillevl 0:13d1767f0c98 11 /**
sillevl 0:13d1767f0c98 12 * System is unusable.
sillevl 0:13d1767f0c98 13 *
sillevl 0:13d1767f0c98 14 * @param string $message
sillevl 0:13d1767f0c98 15 */
Sille Van Landschoot 3:f1457069237f 16 virtual void emergency(const char* message, ...) = 0;
sillevl 0:13d1767f0c98 17
sillevl 0:13d1767f0c98 18 /**
sillevl 0:13d1767f0c98 19 * Action must be taken immediately.
sillevl 0:13d1767f0c98 20 *
sillevl 0:13d1767f0c98 21 * Example: Entire website down, database unavailable, etc. This should
sillevl 0:13d1767f0c98 22 * trigger the SMS alerts and wake you up.
sillevl 0:13d1767f0c98 23 *
sillevl 0:13d1767f0c98 24 * @param string $message
sillevl 0:13d1767f0c98 25 */
Sille Van Landschoot 3:f1457069237f 26 virtual void alert(const char* message, ...) = 0;
sillevl 0:13d1767f0c98 27
sillevl 0:13d1767f0c98 28 /**
sillevl 0:13d1767f0c98 29 * Critical conditions.
sillevl 0:13d1767f0c98 30 *
sillevl 0:13d1767f0c98 31 * Example: Application component unavailable, unexpected exception.
sillevl 0:13d1767f0c98 32 *
sillevl 0:13d1767f0c98 33 * @param string $message
sillevl 0:13d1767f0c98 34 */
Sille Van Landschoot 3:f1457069237f 35 virtual void critical(const char* message, ...) = 0;
sillevl 0:13d1767f0c98 36
sillevl 0:13d1767f0c98 37 /**
sillevl 0:13d1767f0c98 38 * Runtime errors that do not require immediate action but should typically
sillevl 0:13d1767f0c98 39 * be logged and monitored.
sillevl 0:13d1767f0c98 40 *
sillevl 0:13d1767f0c98 41 * @param string $message
sillevl 0:13d1767f0c98 42 */
Sille Van Landschoot 3:f1457069237f 43 virtual void error(const char* message, ...) = 0;
sillevl 0:13d1767f0c98 44
sillevl 0:13d1767f0c98 45 /**
sillevl 0:13d1767f0c98 46 * Exceptional occurrences that are not errors.
sillevl 0:13d1767f0c98 47 *
sillevl 0:13d1767f0c98 48 * Example: Use of deprecated APIs, poor use of an API, undesirable things
sillevl 0:13d1767f0c98 49 * that are not necessarily wrong.
sillevl 0:13d1767f0c98 50 *
sillevl 0:13d1767f0c98 51 * @param string $message
sillevl 0:13d1767f0c98 52 */
Sille Van Landschoot 3:f1457069237f 53 virtual void warning(const char* message, ...) = 0;
sillevl 0:13d1767f0c98 54
sillevl 0:13d1767f0c98 55 /**
sillevl 0:13d1767f0c98 56 * Normal but significant events.
sillevl 0:13d1767f0c98 57 *
sillevl 0:13d1767f0c98 58 * @param string $message
sillevl 0:13d1767f0c98 59 */
Sille Van Landschoot 3:f1457069237f 60 virtual void notice(const char* message, ...) = 0;
sillevl 0:13d1767f0c98 61
sillevl 0:13d1767f0c98 62 /**
sillevl 0:13d1767f0c98 63 * Interesting events.
sillevl 0:13d1767f0c98 64 *
sillevl 0:13d1767f0c98 65 * Example: User logs in, SQL logs.
sillevl 0:13d1767f0c98 66 *
sillevl 0:13d1767f0c98 67 * @param string $message
sillevl 0:13d1767f0c98 68 */
Sille Van Landschoot 3:f1457069237f 69 virtual void info(const char* message, ...) = 0;
sillevl 0:13d1767f0c98 70
sillevl 0:13d1767f0c98 71 /**
sillevl 0:13d1767f0c98 72 * Detailed debug information.
sillevl 0:13d1767f0c98 73 *
sillevl 0:13d1767f0c98 74 * @param string $message
sillevl 0:13d1767f0c98 75 */
Sille Van Landschoot 3:f1457069237f 76 virtual void debug(const char* message, ...) = 0;
sillevl 0:13d1767f0c98 77
sillevl 0:13d1767f0c98 78 /**
sillevl 0:13d1767f0c98 79 * Logs with an arbitrary level.
sillevl 0:13d1767f0c98 80 *
sillevl 0:13d1767f0c98 81 * @param mixed $level
sillevl 0:13d1767f0c98 82 * @param string $message
sillevl 0:13d1767f0c98 83 */
Sille Van Landschoot 3:f1457069237f 84 virtual void log(Level level, const char* message, ...) = 0;
sillevl 1:8ee5fd3c1bf1 85 };
sillevl 1:8ee5fd3c1bf1 86
Sille Van Landschoot 3:f1457069237f 87 }