Browse Source

feat: add logging config

j8
paweldomas 8 years ago
parent
commit
76c89845a8
6 changed files with 63 additions and 8 deletions
  1. 35
    1
      app.js
  2. 0
    2
      conference.js
  3. 2
    0
      index.html
  4. 8
    0
      logging_config.js
  5. 8
    3
      modules/config/URLProcessor.js
  6. 10
    2
      modules/config/Util.js

+ 35
- 1
app.js View File

1
-/* global $, config, getRoomName */
1
+/* global $, config, getRoomName, loggingConfig, JitsiMeetJS */
2
 /* application specific logic */
2
 /* application specific logic */
3
 const logger = require("jitsi-meet-logger").getLogger(__filename);
3
 const logger = require("jitsi-meet-logger").getLogger(__filename);
4
 
4
 
19
 
19
 
20
 window.toastr = require("toastr");
20
 window.toastr = require("toastr");
21
 
21
 
22
+const Logger = require("jitsi-meet-logger");
23
+
22
 import URLProcessor from "./modules/config/URLProcessor";
24
 import URLProcessor from "./modules/config/URLProcessor";
23
 import RoomnameGenerator from './modules/util/RoomnameGenerator';
25
 import RoomnameGenerator from './modules/util/RoomnameGenerator';
24
 
26
 
32
 import getTokenData from "./modules/tokendata/TokenData";
34
 import getTokenData from "./modules/tokendata/TokenData";
33
 import translation from "./modules/translation/translation";
35
 import translation from "./modules/translation/translation";
34
 
36
 
37
+
35
 /**
38
 /**
36
  * Tries to push history state with the following parameters:
39
  * Tries to push history state with the following parameters:
37
  * 'VideoChat', `Room: ${roomName}`, URL. If fail, prints the error and returns
40
  * 'VideoChat', `Room: ${roomName}`, URL. If fail, prints the error and returns
79
     return roomName;
82
     return roomName;
80
 }
83
 }
81
 
84
 
85
+/**
86
+ * Adjusts the logging levels.
87
+ * @private
88
+ */
89
+function configureLoggingLevels () {
90
+    // NOTE The library Logger is separated from the app loggers, so the levels
91
+    // have to be set in two places
92
+
93
+    // Set default logging level
94
+    const defaultLogLevel
95
+        = loggingConfig.defaultLogLevel || JitsiMeetJS.logLevels.TRACE;
96
+    Logger.setLogLevel(defaultLogLevel);
97
+    JitsiMeetJS.setLogLevel(defaultLogLevel);
98
+
99
+    // NOTE console was used on purpose here to go around the logging
100
+    // and always print the default logging level to the console
101
+    console.info("Default logging level set to: " + defaultLogLevel);
102
+
103
+    // Set log level for each logger
104
+    if (loggingConfig) {
105
+        Object.keys(loggingConfig).forEach(function(loggerName) {
106
+            if ('defaultLogLevel' !== loggerName) {
107
+                const level = loggingConfig[loggerName];
108
+                Logger.setLogLevelById(level, loggerName);
109
+                JitsiMeetJS.setLogLevelById(level, loggerName);
110
+            }
111
+        });
112
+    }
113
+}
114
+
82
 const APP = {
115
 const APP = {
83
     // Used by do_external_connect.js if we receive the attach data after
116
     // Used by do_external_connect.js if we receive the attach data after
84
     // connect was already executed. status property can be "initialized",
117
     // connect was already executed. status property can be "initialized",
107
     connection: null,
140
     connection: null,
108
     API,
141
     API,
109
     init () {
142
     init () {
143
+        configureLoggingLevels();
110
         this.keyboardshortcut =
144
         this.keyboardshortcut =
111
             require("./modules/keyboardshortcut/keyboardshortcut");
145
             require("./modules/keyboardshortcut/keyboardshortcut");
112
         this.configFetch = require("./modules/config/HttpConfigFetch");
146
         this.configFetch = require("./modules/config/HttpConfigFetch");

+ 0
- 2
conference.js View File

464
      */
464
      */
465
     init(options) {
465
     init(options) {
466
         this.roomName = options.roomName;
466
         this.roomName = options.roomName;
467
-        JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
468
-
469
         // attaches global error handler, if there is already one, respect it
467
         // attaches global error handler, if there is already one, respect it
470
         if(JitsiMeetJS.getGlobalOnErrorHandler){
468
         if(JitsiMeetJS.getGlobalOnErrorHandler){
471
             var oldOnErrorHandler = window.onerror;
469
             var oldOnErrorHandler = window.onerror;

+ 2
- 0
index.html View File

14
             "utils.js",
14
             "utils.js",
15
             "do_external_connect.js",
15
             "do_external_connect.js",
16
             "interface_config.js",
16
             "interface_config.js",
17
+            "logging_config.js",
17
             "lib-jitsi-meet.min.js",
18
             "lib-jitsi-meet.min.js",
18
             "app.bundle.min.js",
19
             "app.bundle.min.js",
19
             "all.css"
20
             "all.css"
43
     <!--#include virtual="connection_optimization/connection_optimization.html" -->
44
     <!--#include virtual="connection_optimization/connection_optimization.html" -->
44
     <script src="connection_optimization/do_external_connect.js?v=1"></script>
45
     <script src="connection_optimization/do_external_connect.js?v=1"></script>
45
     <script><!--#include virtual="/interface_config.js" --></script>
46
     <script><!--#include virtual="/interface_config.js" --></script>
47
+    <script><!--#include virtual="/logging_config.js" --></script>
46
     <script src="libs/lib-jitsi-meet.min.js?v=139"></script>
48
     <script src="libs/lib-jitsi-meet.min.js?v=139"></script>
47
     <script src="libs/app.bundle.min.js?v=139"></script>
49
     <script src="libs/app.bundle.min.js?v=139"></script>
48
     <!--#include virtual="title.html" -->
50
     <!--#include virtual="title.html" -->

+ 8
- 0
logging_config.js View File

1
+// Logging configuration
2
+var loggingConfig = { // eslint-disable-line no-unused-vars
3
+    //default log level for the app and lib-jitsi-meet
4
+    //defaultLogLevel: 'trace',
5
+    // Examples:
6
+    //'modules/version/ComponentsVersions.js': 'info',
7
+    //'modules/xmpp/ChatRoom.js': 'log'
8
+};

+ 8
- 3
modules/config/URLProcessor.js View File

1
-/* global config, interfaceConfig, getConfigParamsFromUrl */
1
+/* global config, interfaceConfig, loggingConfig, getConfigParamsFromUrl */
2
 const logger = require("jitsi-meet-logger").getLogger(__filename);
2
 const logger = require("jitsi-meet-logger").getLogger(__filename);
3
 
3
 
4
 var configUtils = require('./Util');
4
 var configUtils = require('./Util');
27
         // }
27
         // }
28
         var configJSON = {
28
         var configJSON = {
29
             config: {},
29
             config: {},
30
-            interfaceConfig: {}
30
+            interfaceConfig: {},
31
+            loggingConfig: {}
31
         };
32
         };
32
         for (var key in params) {
33
         for (var key in params) {
33
             if (typeof key !== "string") {
34
             if (typeof key !== "string") {
47
             } else if (key.indexOf("interfaceConfig.") === 0) {
48
             } else if (key.indexOf("interfaceConfig.") === 0) {
48
                 confObj = configJSON.interfaceConfig;
49
                 confObj = configJSON.interfaceConfig;
49
                 confKey = key.substr("interfaceConfig.".length);
50
                 confKey = key.substr("interfaceConfig.".length);
51
+            } else if (key.indexOf("loggingConfig.") === 0) {
52
+                confObj = configJSON.loggingConfig;
53
+                confKey = key.substr("loggingConfig.".length);
50
             }
54
             }
51
 
55
 
52
             if (!confObj)
56
             if (!confObj)
54
 
58
 
55
             confObj[confKey] = params[key];
59
             confObj[confKey] = params[key];
56
         }
60
         }
57
-        configUtils.overrideConfigJSON(config, interfaceConfig, configJSON);
61
+        configUtils.overrideConfigJSON(
62
+            config, interfaceConfig, loggingConfig, configJSON);
58
     }
63
     }
59
 };
64
 };
60
 
65
 

+ 10
- 2
modules/config/Util.js View File

7
      * @param config the config object for which we'll be overriding properties
7
      * @param config the config object for which we'll be overriding properties
8
      * @param interfaceConfig the interfaceConfig object for which we'll be
8
      * @param interfaceConfig the interfaceConfig object for which we'll be
9
      *                        overriding properties.
9
      *                        overriding properties.
10
+     * @param loggingConfig the logging config object for which we'll be
11
+     *        overriding properties.
10
      * @param newConfig object containing configuration properties. Destination
12
      * @param newConfig object containing configuration properties. Destination
11
      *        object is selected based on root property name:
13
      *        object is selected based on root property name:
12
      *        {
14
      *        {
14
      *             // config.js properties to be
16
      *             // config.js properties to be
15
      *          },
17
      *          },
16
      *          interfaceConfig: {
18
      *          interfaceConfig: {
17
-     *             // interfaceConfig.js properties here
19
+     *             // interface_config.js properties here
20
+     *          },
21
+     *          loggingConfig: {
22
+     *             // logging_config.js properties here
18
      *          }
23
      *          }
19
      *        }
24
      *        }
20
      */
25
      */
21
-    overrideConfigJSON: function (config, interfaceConfig, newConfig) {
26
+    overrideConfigJSON: function (config,
27
+                                  interfaceConfig, loggingConfig, newConfig) {
22
         var configRoot, key, value, confObj;
28
         var configRoot, key, value, confObj;
23
         for (configRoot in newConfig) {
29
         for (configRoot in newConfig) {
24
             confObj = null;
30
             confObj = null;
26
                 confObj = config;
32
                 confObj = config;
27
             } else if (configRoot == "interfaceConfig") {
33
             } else if (configRoot == "interfaceConfig") {
28
                 confObj = interfaceConfig;
34
                 confObj = interfaceConfig;
35
+            } else if (configRoot == "loggingConfig") {
36
+                confObj = loggingConfig;
29
             } else {
37
             } else {
30
                 continue;
38
                 continue;
31
             }
39
             }

Loading…
Cancel
Save