Skip to content

Commit

Permalink
fix: resolved #317
Browse files Browse the repository at this point in the history
  • Loading branch information
lemanzhang committed Apr 27, 2019
1 parent f581373 commit e555f55
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
9 changes: 3 additions & 6 deletions bin/proxy/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const cpuUtil = require('util/cpu.js');
const fs = require('fs');
const serverOS = require('util/isWindows.js');
const mail = require('util/mail/mail.js');
const { debugOptions } = process.binding('config');
const methodMap = {};
const workerMap = {};
const cpuMap = [];
Expand Down Expand Up @@ -94,13 +93,11 @@ process.on('unhandledRejection', (errorOrReason, currPromise) => {

startServer();


// 通过cluster启动master && worker
function startServer() {

let useWorker = true;

if (debugOptions.inspectorEnabled) {
const useInspectFlag = process.execArgv.join().includes('inspect');
if (useInspectFlag) {
useWorker = false;
}

Expand Down Expand Up @@ -161,7 +158,7 @@ function startServer() {
require('runtime/md5.checker.js').check();
}, 30 * 60000);

if (cluster.isMaster && debugOptions.inspectorEnabled) {
if (cluster.isMaster && useInspectFlag) {
logger.setLogLevel('info');
logger.info('inspectorEnabled, start listening');
process.emit('message', {
Expand Down
5 changes: 2 additions & 3 deletions bin/tsw/util/logger/logger.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
*/
'use strict';


const { debugOptions } = process.binding('config');
const useInspectFlag = process.execArgv.join().includes('inspect');

this.levelMap = {
'debug': 10,
Expand All @@ -23,7 +22,7 @@ this.logLevel = null;

this.getLogLevel = function() {

if (debugOptions && debugOptions.inspectorEnabled) {
if (useInspectFlag) {
return this.levelMap['debug'];
}

Expand Down
6 changes: 3 additions & 3 deletions bin/tsw/util/logger/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const util = require('util');
const contextMod = require('context.js');
const callInfo = require('./callInfo.js');
const { isWin32Like } = require('util/isWindows.js');
const { debugOptions } = process.binding('config');
const tnm2 = require('api/tnm2');
const canIuse = /^[0-9a-zA-Z_-]{0,64}$/;
const cache = global[__filename] || {
Expand Down Expand Up @@ -301,10 +300,11 @@ Logger.prototype = {
},

writeLog: function(type, str, obj) {

const level = this.type2level(type);
const log = this.getLog();
const allow = filter(level, str, obj);
const useInspectFlag = process.execArgv.join().includes('inspect');

let logStr = null;

if (log || allow === true || level >= config.getLogLevel()) {
Expand All @@ -322,7 +322,7 @@ Logger.prototype = {
return this;
}

if (debugOptions && debugOptions.inspectorEnabled) {
if (useInspectFlag) {
// Chrome写入原始日志
this.fillInspect(logStr, level);
// 控制台写入高亮日志
Expand Down

0 comments on commit e555f55

Please sign in to comment.