Use window.log in browser context, turn on console eslint rule
This commit is contained in:
		
					parent
					
						
							
								4320b125dd
							
						
					
				
			
			
				commit
				
					
						5933a34a18
					
				
			
		
					 71 changed files with 816 additions and 559 deletions
				
			
		| 
						 | 
				
			
			@ -6,6 +6,7 @@ const is = require('@sindresorhus/is');
 | 
			
		|||
 | 
			
		||||
/* global Buffer: false */
 | 
			
		||||
/* global setTimeout: false */
 | 
			
		||||
/* global log: false */
 | 
			
		||||
 | 
			
		||||
/* eslint-disable more/no-then, no-bitwise, no-nested-ternary */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +160,7 @@ function _createSocket(url, { certificateAuthority, proxyUrl }) {
 | 
			
		|||
function _promiseAjax(providedUrl, options) {
 | 
			
		||||
  return new Promise((resolve, reject) => {
 | 
			
		||||
    const url = providedUrl || `${options.host}/${options.path}`;
 | 
			
		||||
    console.log(options.type, url);
 | 
			
		||||
    log.info(options.type, url);
 | 
			
		||||
    const timeout =
 | 
			
		||||
      typeof options.timeout !== 'undefined' ? options.timeout : 10000;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -220,7 +221,7 @@ function _promiseAjax(providedUrl, options) {
 | 
			
		|||
          if (options.responseType === 'json') {
 | 
			
		||||
            if (options.validateResponse) {
 | 
			
		||||
              if (!_validateResponse(result, options.validateResponse)) {
 | 
			
		||||
                console.log(options.type, url, response.status, 'Error');
 | 
			
		||||
                log.error(options.type, url, response.status, 'Error');
 | 
			
		||||
                reject(
 | 
			
		||||
                  HTTPError(
 | 
			
		||||
                    'promiseAjax: invalid response',
 | 
			
		||||
| 
						 | 
				
			
			@ -233,10 +234,10 @@ function _promiseAjax(providedUrl, options) {
 | 
			
		|||
            }
 | 
			
		||||
          }
 | 
			
		||||
          if (response.status >= 0 && response.status < 400) {
 | 
			
		||||
            console.log(options.type, url, response.status, 'Success');
 | 
			
		||||
            log.info(options.type, url, response.status, 'Success');
 | 
			
		||||
            resolve(result, response.status);
 | 
			
		||||
          } else {
 | 
			
		||||
            console.log(options.type, url, response.status, 'Error');
 | 
			
		||||
            log.error(options.type, url, response.status, 'Error');
 | 
			
		||||
            reject(
 | 
			
		||||
              HTTPError(
 | 
			
		||||
                'promiseAjax: error response',
 | 
			
		||||
| 
						 | 
				
			
			@ -249,7 +250,7 @@ function _promiseAjax(providedUrl, options) {
 | 
			
		|||
        });
 | 
			
		||||
      })
 | 
			
		||||
      .catch(e => {
 | 
			
		||||
        console.log(options.type, url, 0, 'Error');
 | 
			
		||||
        log.error(options.type, url, 0, 'Error');
 | 
			
		||||
        const stack = `${e.stack}\nInitial stack:\n${options.stack}`;
 | 
			
		||||
        reject(HTTPError('promiseAjax catch', 0, e.toString(), stack));
 | 
			
		||||
      });
 | 
			
		||||
| 
						 | 
				
			
			@ -650,7 +651,7 @@ function initialize({ url, cdnUrl, certificateAuthority, proxyUrl }) {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    function getMessageSocket() {
 | 
			
		||||
      console.log('opening message socket', url);
 | 
			
		||||
      log.info('opening message socket', url);
 | 
			
		||||
      const fixedScheme = url
 | 
			
		||||
        .replace('https://', 'wss://')
 | 
			
		||||
        .replace('http://', 'ws://');
 | 
			
		||||
| 
						 | 
				
			
			@ -664,7 +665,7 @@ function initialize({ url, cdnUrl, certificateAuthority, proxyUrl }) {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    function getProvisioningSocket() {
 | 
			
		||||
      console.log('opening provisioning socket', url);
 | 
			
		||||
      log.info('opening provisioning socket', url);
 | 
			
		||||
      const fixedScheme = url
 | 
			
		||||
        .replace('https://', 'wss://')
 | 
			
		||||
        .replace('http://', 'ws://');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue