backendless 7.0.1 → 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.
@@ -17,12 +17,19 @@ var Logging = /*#__PURE__*/function () {
17
17
  (0, _classCallCheck2["default"])(this, Logging);
18
18
  this.app = app;
19
19
  this.reset();
20
- this.setConfig(app.loggingConfig);
20
+ if (app.loggingConfig) {
21
+ this.setConfig(app.loggingConfig);
22
+ }
21
23
  }
22
24
  (0, _createClass2["default"])(Logging, [{
23
25
  key: "setConfig",
24
26
  value: function setConfig(config) {
25
- this.config = config;
27
+ if (config.levels) {
28
+ this.levels = config.levels;
29
+ }
30
+ if (config.defaultLevel) {
31
+ this.defaultLevel = config.defaultLevel;
32
+ }
26
33
  if (config.loadLevels) {
27
34
  this.loadLoggingLevels();
28
35
  }
@@ -30,6 +37,8 @@ var Logging = /*#__PURE__*/function () {
30
37
  }, {
31
38
  key: "reset",
32
39
  value: function reset() {
40
+ this.levels = {};
41
+ this.defaultLevel = 'all';
33
42
  this.loggers = {};
34
43
  this.messages = [];
35
44
  this.numOfMessages = 10;
@@ -44,9 +53,9 @@ var Logging = /*#__PURE__*/function () {
44
53
  url: this.app.urls.loggingLevels()
45
54
  }).then(function (loggers) {
46
55
  loggers.forEach(function (logger) {
47
- _this.config.levels[logger.name] = logger.level;
56
+ _this.levels[logger.name] = logger.level;
48
57
  });
49
- _this.config.defaultLevel = _this.config.levels[GLOBAL_LOGGER_NAME] || _this.config.defaultLevel;
58
+ _this.defaultLevel = _this.levels[GLOBAL_LOGGER_NAME] || _this.defaultLevel;
50
59
  })["catch"](function (error) {
51
60
  // eslint-disable-next-line no-console
52
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
  }]);
@@ -17,12 +17,19 @@ var Logging = /*#__PURE__*/function () {
17
17
  (0, _classCallCheck2["default"])(this, Logging);
18
18
  this.app = app;
19
19
  this.reset();
20
- this.setConfig(app.loggingConfig);
20
+ if (app.loggingConfig) {
21
+ this.setConfig(app.loggingConfig);
22
+ }
21
23
  }
22
24
  (0, _createClass2["default"])(Logging, [{
23
25
  key: "setConfig",
24
26
  value: function setConfig(config) {
25
- this.config = config;
27
+ if (config.levels) {
28
+ this.levels = config.levels;
29
+ }
30
+ if (config.defaultLevel) {
31
+ this.defaultLevel = config.defaultLevel;
32
+ }
26
33
  if (config.loadLevels) {
27
34
  this.loadLoggingLevels();
28
35
  }
@@ -30,6 +37,8 @@ var Logging = /*#__PURE__*/function () {
30
37
  }, {
31
38
  key: "reset",
32
39
  value: function reset() {
40
+ this.levels = {};
41
+ this.defaultLevel = 'all';
33
42
  this.loggers = {};
34
43
  this.messages = [];
35
44
  this.numOfMessages = 10;
@@ -44,9 +53,9 @@ var Logging = /*#__PURE__*/function () {
44
53
  url: this.app.urls.loggingLevels()
45
54
  }).then(function (loggers) {
46
55
  loggers.forEach(function (logger) {
47
- _this.config.levels[logger.name] = logger.level;
56
+ _this.levels[logger.name] = logger.level;
48
57
  });
49
- _this.config.defaultLevel = _this.config.levels[GLOBAL_LOGGER_NAME] || _this.config.defaultLevel;
58
+ _this.defaultLevel = _this.levels[GLOBAL_LOGGER_NAME] || _this.defaultLevel;
50
59
  })["catch"](function (error) {
51
60
  // eslint-disable-next-line no-console
52
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.1",
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",
@@ -9,11 +9,19 @@ export default class Logging {
9
9
 
10
10
  this.reset()
11
11
 
12
- this.setConfig(app.loggingConfig)
12
+ if (app.loggingConfig) {
13
+ this.setConfig(app.loggingConfig)
14
+ }
13
15
  }
14
16
 
15
17
  setConfig(config) {
16
- this.config = config
18
+ if (config.levels) {
19
+ this.levels = config.levels
20
+ }
21
+
22
+ if (config.defaultLevel) {
23
+ this.defaultLevel = config.defaultLevel
24
+ }
17
25
 
18
26
  if (config.loadLevels) {
19
27
  this.loadLoggingLevels()
@@ -21,6 +29,8 @@ export default class Logging {
21
29
  }
22
30
 
23
31
  reset() {
32
+ this.levels = {}
33
+ this.defaultLevel = 'all'
24
34
  this.loggers = {}
25
35
  this.messages = []
26
36
  this.numOfMessages = 10
@@ -33,10 +43,10 @@ export default class Logging {
33
43
  .get({ url: this.app.urls.loggingLevels() })
34
44
  .then(loggers => {
35
45
  loggers.forEach(logger => {
36
- this.config.levels[logger.name] = logger.level
46
+ this.levels[logger.name] = logger.level
37
47
  })
38
48
 
39
- this.config.defaultLevel = this.config.levels[GLOBAL_LOGGER_NAME] || this.config.defaultLevel
49
+ this.defaultLevel = this.levels[GLOBAL_LOGGER_NAME] || this.defaultLevel
40
50
  })
41
51
  .catch(error => {
42
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
  }