Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolved Tencent/TSW#317 #318

Merged
merged 1 commit into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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