backendless 7.0.0 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,17 +11,25 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
11
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
13
  var _logger = _interopRequireDefault(require("./logger"));
14
+ var GLOBAL_LOGGER_NAME = 'Global logger';
14
15
  var Logging = /*#__PURE__*/function () {
15
16
  function Logging(app) {
16
17
  (0, _classCallCheck2["default"])(this, Logging);
17
18
  this.app = app;
18
19
  this.reset();
19
- this.setConfig(app.loggingConfig);
20
+ if (app.loggingConfig) {
21
+ this.setConfig(app.loggingConfig);
22
+ }
20
23
  }
21
24
  (0, _createClass2["default"])(Logging, [{
22
25
  key: "setConfig",
23
26
  value: function setConfig(config) {
24
- this.config = config;
27
+ if (config.levels) {
28
+ this.levels = config.levels;
29
+ }
30
+ if (config.defaultLevel) {
31
+ this.defaultLevel = config.defaultLevel;
32
+ }
25
33
  if (config.loadLevels) {
26
34
  this.loadLoggingLevels();
27
35
  }
@@ -29,6 +37,8 @@ var Logging = /*#__PURE__*/function () {
29
37
  }, {
30
38
  key: "reset",
31
39
  value: function reset() {
40
+ this.levels = {};
41
+ this.defaultLevel = 'all';
32
42
  this.loggers = {};
33
43
  this.messages = [];
34
44
  this.numOfMessages = 10;
@@ -43,8 +53,9 @@ var Logging = /*#__PURE__*/function () {
43
53
  url: this.app.urls.loggingLevels()
44
54
  }).then(function (loggers) {
45
55
  loggers.forEach(function (logger) {
46
- _this.config.levels[logger.name] = logger.level;
56
+ _this.levels[logger.name] = logger.level;
47
57
  });
58
+ _this.defaultLevel = _this.levels[GLOBAL_LOGGER_NAME] || _this.defaultLevel;
48
59
  })["catch"](function (error) {
49
60
  // eslint-disable-next-line no-console
50
61
  console.error('Could not load logging levels: ', error);
@@ -63,11 +63,7 @@ var Logger = /*#__PURE__*/function () {
63
63
  }, {
64
64
  key: "min",
65
65
  value: function min(level) {
66
- var configuredLevel = this.logging.config.levels[this.name];
67
- if (!configuredLevel) {
68
- var defaultLevel = this.logging.config.defaultLevel;
69
- return LogLevelPriorities[defaultLevel.toLowerCase()] >= LogLevelPriorities[level.toLowerCase()];
70
- }
66
+ var configuredLevel = this.logging.levels[this.name] || this.logging.defaultLevel;
71
67
  return LogLevelPriorities[configuredLevel.toLowerCase()] >= LogLevelPriorities[level.toLowerCase()];
72
68
  }
73
69
  }]);
@@ -11,17 +11,25 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
11
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
13
  var _logger = _interopRequireDefault(require("./logger"));
14
+ var GLOBAL_LOGGER_NAME = 'Global logger';
14
15
  var Logging = /*#__PURE__*/function () {
15
16
  function Logging(app) {
16
17
  (0, _classCallCheck2["default"])(this, Logging);
17
18
  this.app = app;
18
19
  this.reset();
19
- this.setConfig(app.loggingConfig);
20
+ if (app.loggingConfig) {
21
+ this.setConfig(app.loggingConfig);
22
+ }
20
23
  }
21
24
  (0, _createClass2["default"])(Logging, [{
22
25
  key: "setConfig",
23
26
  value: function setConfig(config) {
24
- this.config = config;
27
+ if (config.levels) {
28
+ this.levels = config.levels;
29
+ }
30
+ if (config.defaultLevel) {
31
+ this.defaultLevel = config.defaultLevel;
32
+ }
25
33
  if (config.loadLevels) {
26
34
  this.loadLoggingLevels();
27
35
  }
@@ -29,6 +37,8 @@ var Logging = /*#__PURE__*/function () {
29
37
  }, {
30
38
  key: "reset",
31
39
  value: function reset() {
40
+ this.levels = {};
41
+ this.defaultLevel = 'all';
32
42
  this.loggers = {};
33
43
  this.messages = [];
34
44
  this.numOfMessages = 10;
@@ -43,8 +53,9 @@ var Logging = /*#__PURE__*/function () {
43
53
  url: this.app.urls.loggingLevels()
44
54
  }).then(function (loggers) {
45
55
  loggers.forEach(function (logger) {
46
- _this.config.levels[logger.name] = logger.level;
56
+ _this.levels[logger.name] = logger.level;
47
57
  });
58
+ _this.defaultLevel = _this.levels[GLOBAL_LOGGER_NAME] || _this.defaultLevel;
48
59
  })["catch"](function (error) {
49
60
  // eslint-disable-next-line no-console
50
61
  console.error('Could not load logging levels: ', error);
@@ -63,11 +63,7 @@ var Logger = /*#__PURE__*/function () {
63
63
  }, {
64
64
  key: "min",
65
65
  value: function min(level) {
66
- var configuredLevel = this.logging.config.levels[this.name];
67
- if (!configuredLevel) {
68
- var defaultLevel = this.logging.config.defaultLevel;
69
- return LogLevelPriorities[defaultLevel.toLowerCase()] >= LogLevelPriorities[level.toLowerCase()];
70
- }
66
+ var configuredLevel = this.logging.levels[this.name] || this.logging.defaultLevel;
71
67
  return LogLevelPriorities[configuredLevel.toLowerCase()] >= LogLevelPriorities[level.toLowerCase()];
72
68
  }
73
69
  }]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backendless",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "Backendless JavaScript SDK for Node.js and the browser",
5
5
  "browser": "dist/backendless.js",
6
6
  "main": "lib/index.js",
@@ -1,5 +1,7 @@
1
1
  import Logger from './logger'
2
2
 
3
+ const GLOBAL_LOGGER_NAME = 'Global logger'
4
+
3
5
  export default class Logging {
4
6
 
5
7
  constructor(app) {
@@ -7,11 +9,19 @@ export default class Logging {
7
9
 
8
10
  this.reset()
9
11
 
10
- this.setConfig(app.loggingConfig)
12
+ if (app.loggingConfig) {
13
+ this.setConfig(app.loggingConfig)
14
+ }
11
15
  }
12
16
 
13
17
  setConfig(config) {
14
- this.config = config
18
+ if (config.levels) {
19
+ this.levels = config.levels
20
+ }
21
+
22
+ if (config.defaultLevel) {
23
+ this.defaultLevel = config.defaultLevel
24
+ }
15
25
 
16
26
  if (config.loadLevels) {
17
27
  this.loadLoggingLevels()
@@ -19,6 +29,8 @@ export default class Logging {
19
29
  }
20
30
 
21
31
  reset() {
32
+ this.levels = {}
33
+ this.defaultLevel = 'all'
22
34
  this.loggers = {}
23
35
  this.messages = []
24
36
  this.numOfMessages = 10
@@ -31,8 +43,10 @@ export default class Logging {
31
43
  .get({ url: this.app.urls.loggingLevels() })
32
44
  .then(loggers => {
33
45
  loggers.forEach(logger => {
34
- this.config.levels[logger.name] = logger.level
46
+ this.levels[logger.name] = logger.level
35
47
  })
48
+
49
+ this.defaultLevel = this.levels[GLOBAL_LOGGER_NAME] || this.defaultLevel
36
50
  })
37
51
  .catch(error => {
38
52
  // eslint-disable-next-line no-console
@@ -47,13 +47,7 @@ export default class Logger {
47
47
  }
48
48
 
49
49
  min(level) {
50
- const configuredLevel = this.logging.config.levels[this.name]
51
-
52
- if (!configuredLevel) {
53
- const { defaultLevel } = this.logging.config
54
-
55
- return LogLevelPriorities[defaultLevel.toLowerCase()] >= LogLevelPriorities[level.toLowerCase()]
56
- }
50
+ const configuredLevel = this.logging.levels[this.name] || this.logging.defaultLevel
57
51
 
58
52
  return LogLevelPriorities[configuredLevel.toLowerCase()] >= LogLevelPriorities[level.toLowerCase()]
59
53
  }