提交 ea7a6b80 编写于 作者: J Joao Moreno

fix logs formatter

上级 7a8436c6
......@@ -53,7 +53,7 @@ function createServices(args: ParsedArgs): IInstantiationService {
const logService = new MultiplexLogService([legacyLogService, spdlogService]);
registerGlobalLogService(logService);
logService.info('main', process.argv);
logService.info('main', JSON.stringify(args));
// Eventually cleanup
setTimeout(() => spdlogService.cleanup().then(null, err => console.error(err)), 10000);
......
......@@ -20,7 +20,6 @@ export class SpdLogService implements ILogService {
private logger: RotatingLogger;
private disposables: IDisposable[] = [];
private formatRegexp = /{(\d+)}/g;
constructor(
processName: string,
......@@ -83,24 +82,16 @@ export class SpdLogService implements ILogService {
this.disposables = dispose(this.disposables);
}
private format(value: string, ...args: any[]): string {
if (args.length) {
value = value.replace(this.formatRegexp, (match, group) => {
let idx = parseInt(group, 10);
return isNaN(idx) || idx < 0 || idx >= args.length ?
match :
this.toStringValue(args[idx]);
});
}
return value;
}
private toStringValue(value: any): string {
if (typeof value === 'object') {
try {
return JSON.stringify(value);
} catch (e) { }
}
return value;
private format(value: string, args: any[] = []): string {
const strs = args.map(a => {
if (typeof a === 'object') {
try {
return JSON.stringify(a);
} catch (e) { }
}
return a;
});
return [value, ...strs].join(' ');
}
}
\ No newline at end of file
......@@ -31,14 +31,15 @@ registerCommands();
const viewCategory = nls.localize('view', "View");
const helpCategory = nls.localize('help', "Help");
const fileCategory = nls.localize('file', "File");
const logCategory = nls.localize('logs', "Logs");
const workbenchActionsRegistry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(NewWindowAction, NewWindowAction.ID, NewWindowAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_N }), 'New Window');
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseCurrentWindowAction, CloseCurrentWindowAction.ID, CloseCurrentWindowAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_W }), 'Close Window');
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(SwitchWindow, SwitchWindow.ID, SwitchWindow.LABEL, { primary: null, mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_W } }), 'Switch Window...');
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(QuickSwitchWindow, QuickSwitchWindow.ID, QuickSwitchWindow.LABEL), 'Quick Switch Window...');
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowLogsAction, ShowLogsAction.ID, ShowLogsAction.LABEL), 'Show Logs...');
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenLogsFolderAction, OpenLogsFolderAction.ID, OpenLogsFolderAction.LABEL), 'Open Log Folder');
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(SetLogLevelAction, SetLogLevelAction.ID, SetLogLevelAction.LABEL), 'Set Log Level');
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowLogsAction, ShowLogsAction.ID, ShowLogsAction.LABEL), 'Logs: Show Logs...', logCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenLogsFolderAction, OpenLogsFolderAction.ID, OpenLogsFolderAction.LABEL), 'Logs: Open Log Folder', logCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(SetLogLevelAction, SetLogLevelAction.ID, SetLogLevelAction.LABEL), 'Logs: Set Log Level', logCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenRecentAction, QuickOpenRecentAction.ID, QuickOpenRecentAction.LABEL), 'File: Quick Open Recent...', fileCategory);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册