1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/ReactNativeClient/lib/log.js

40 lines
718 B
JavaScript
Raw Normal View History

2017-05-07 23:02:17 +02:00
// Custom wrapper for `console` to allow for custom logging (to file, etc.) if needed.
class Log {
2017-05-14 23:51:45 +02:00
static setLevel(v) {
this.level_ = v;
}
static level() {
2017-06-11 23:11:14 +02:00
return this.level_ === undefined ? Log.LEVEL_DEBUG : this.level_;
2017-05-14 23:51:45 +02:00
}
2017-05-11 22:14:01 +02:00
static debug(...o) {
2017-05-14 23:51:45 +02:00
if (Log.level() > Log.LEVEL_DEBUG) return;
2017-06-11 23:11:14 +02:00
console.info(...o);
2017-05-11 22:14:01 +02:00
}
2017-05-07 23:02:17 +02:00
static info(...o) {
2017-05-14 23:51:45 +02:00
if (Log.level() > Log.LEVEL_INFO) return;
2017-05-07 23:02:17 +02:00
console.info(...o);
}
static warn(...o) {
2017-05-14 23:51:45 +02:00
if (Log.level() > Log.LEVEL_WARN) return;
2017-05-07 23:02:17 +02:00
console.info(...o);
}
static error(...o) {
2017-05-14 23:51:45 +02:00
if (Log.level() > Log.LEVEL_ERROR) return;
2017-05-07 23:02:17 +02:00
console.info(...o);
}
}
2017-05-14 23:51:45 +02:00
Log.LEVEL_DEBUG = 0;
Log.LEVEL_INFO = 10;
Log.LEVEL_WARN = 20;
Log.LEVEL_ERROR = 30;
2017-11-03 02:13:17 +02:00
module.exports = { Log };