Skip to content

Development&Debugging: Logger options

Tamius Han edited this page May 29, 2020 · 5 revisions

When using logger to log data, you can (must) pass some options to the Logger object.

Initialization

How a logger is created

const logger = new Logger();
await logger.init(loggerOptions);

Where the logger is created

  • src/ext/uw.js
  • src/ext/uw-bg.js
  • TODO: popup, settings page

The logger is passed to all other classes (that need it) via constructor in some way (varies from class to class)

loggerOptions

{
  allowLogging: true,   // whether logging can be enabled or not.
  timeout: 3,           // stop logging after this many seconds after logger init
  fileOptions: {        // Options for writing log to file 
    enabled: true,      // 'false' if logging to file is disabled.
                        // 'true' + allowLogging=true enables logging to file
    // Enable logging of only certain kind of messages
    'debug': true,      // general logs
    'init': true,       // things related to extension initialization
    'settings': true,   // things related to saving and loading extension settings
    'keyboard': true,   // log keypresses
    'mousemove': true,  // log mousemove events while mouse is moving above video player
    'actionHandler': true, // actionHandler decodes keyboard keys and popup button presses
                           // and converts them into commands that the rest of the extension
                           // can understand
    'comms': true,      // logs made by the components that allow content script, background
                        // script and popup to communicate.
    'playerDetect': true,  // log things related to player element detection
    'resizer': true,    // log things from component that resizes the video element
    'scaler': true,     // log things from component that calculates aspect ratio
    'stretcher': true,  // log things from component that calculates video stretching
    'zoom': true,       // log things from pan&zoom component (this option may be useless)
    'videoRescan': true,// log periodic videoRescan events, trying to detect <video> style
                        // changes (may produce lots of logs)
    'playerRescan': true,  // same but for detecting player element instead of <video> style
    'arDetect': true,   // log automatic aspect ratio detection (this is periodic, may create
                        // big logs)
    'arDetect_verbose': true,  // ↑ this ↑ but with extra pedantry 
  },
  consoleOptions: {
     // literally same options as in fileOptions
  },
  allowBlacklistedOrigins: {  // some periodic functions cause more logging than the others,
                              // even downstream. Some logs are thus supressed regardless of
                              // whether the component from which the log is being made is 
                              // enabled in consoleOptions or fileOptions.
                              // most notably:
    'periodicPlayerCheck': true,           // don't log stuff from periodic player refreshes
    'periodicVideoStyleChangeCheck': true, // ↑ this but for periodic video style change checks
    'handleMouseMove': true,               // ↑ this but for everything originating in mousemove
  }

}

Logger options, but it's copypasta time

{
  "allowLogging": true,
  "timeout": 3,
    "consoleOptions": {
    "enabled": true,
    "debug": true,
    "init": true,
    "settings": true,
    "keyboard": true,
    "mousemove": true,
    "actionHandler": true,
    "comms": true,
    "playerDetect": true,
    "resizer": true,
    "scaler": true,
    "stretcher": true,
    "zoom": true,
    "videoRescan": true,
    "playerRescan": true,
    "arDetect": true,
    "arDetect_verbose": true
  },
  "allowBlacklistedOrigins": {
    "periodicPlayerCheck": true,
    "periodicVideoStyleChangeCheck": true,
    "handleMouseMove": true
  }
}