blob: 9c1fd0f8fafa85f6a3991f705bac6ac04231df10 (
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
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { Log } from "resource://gre/modules/Log.sys.mjs";
const ROOT_LOGGER_NAME = "app.normandy";
let rootLogger = null;
export var LogManager = {
/**
* Configure the root logger for the Recipe Client. Must be called at
* least once before using any loggers created via getLogger.
* @param {Number} loggingLevel
* Logging level to use as defined in Log.sys.mjs
*/
configure(loggingLevel) {
if (!rootLogger) {
rootLogger = Log.repository.getLogger(ROOT_LOGGER_NAME);
rootLogger.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter()));
}
rootLogger.level = loggingLevel;
},
/**
* Obtain a named logger with the recipe client logger as its parent.
* @param {String} name
* Name of the logger to obtain.
* @return {Logger}
*/
getLogger(name) {
return Log.repository.getLogger(`${ROOT_LOGGER_NAME}.${name}`);
},
};
|