UNPKG

1.33 kBJavaScriptView Raw
1/*
2Copyright 2018 André Jaenisch
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17/**
18 * @module logger
19 */
20const log = require("loglevel");
21
22// This is to demonstrate, that you can use any namespace you want.
23// Namespaces allow you to turn on/off the logging for specific parts of the
24// application.
25// An idea would be to control this via an environment variable (on Node.js).
26// See https://www.npmjs.com/package/debug to see how this could be implemented
27// Part of #332 is introducing a logging library in the first place.
28const DEFAULT_NAME_SPACE = "matrix";
29const logger = log.getLogger(DEFAULT_NAME_SPACE);
30logger.setLevel(log.levels.DEBUG);
31
32/**
33 * Drop-in replacement for <code>console</code> using {@link https://www.npmjs.com/package/loglevel|loglevel}.
34 * Can be tailored down to specific use cases if needed.
35*/
36module.exports = logger;