Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9914a95d
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9914a95d
编写于
1月 09, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
buffer spdlog calls in main until singleton
fixes #41218
上级
e5cbf755
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
120 addition
and
17 deletion
+120
-17
src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
.../code/electron-browser/sharedProcess/sharedProcessMain.ts
+2
-2
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+14
-6
src/vs/code/node/cliProcessMain.ts
src/vs/code/node/cliProcessMain.ts
+2
-2
src/vs/platform/log/common/bufferLog.ts
src/vs/platform/log/common/bufferLog.ts
+95
-0
src/vs/platform/log/node/spdlogService.ts
src/vs/platform/log/node/spdlogService.ts
+1
-1
src/vs/workbench/api/node/extHostLogService.ts
src/vs/workbench/api/node/extHostLogService.ts
+2
-2
src/vs/workbench/electron-browser/main.ts
src/vs/workbench/electron-browser/main.ts
+2
-2
src/vs/workbench/node/extensionHostMain.ts
src/vs/workbench/node/extensionHostMain.ts
+2
-2
未找到文件。
src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
浏览文件 @
9914a95d
...
@@ -37,7 +37,7 @@ import { WindowsChannelClient } from 'vs/platform/windows/common/windowsIpc';
...
@@ -37,7 +37,7 @@ import { WindowsChannelClient } from 'vs/platform/windows/common/windowsIpc';
import
{
ipcRenderer
}
from
'
electron
'
;
import
{
ipcRenderer
}
from
'
electron
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
createSharedProcessContributions
}
from
'
vs/code/electron-browser/sharedProcess/contrib/contributions
'
;
import
{
createSharedProcessContributions
}
from
'
vs/code/electron-browser/sharedProcess/contrib/contributions
'
;
import
{
createLogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
create
Spd
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
export
interface
ISharedProcessConfiguration
{
export
interface
ISharedProcessConfiguration
{
...
@@ -81,7 +81,7 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I
...
@@ -81,7 +81,7 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I
const
services
=
new
ServiceCollection
();
const
services
=
new
ServiceCollection
();
const
environmentService
=
new
EnvironmentService
(
initData
.
args
,
process
.
execPath
);
const
environmentService
=
new
EnvironmentService
(
initData
.
args
,
process
.
execPath
);
const
logService
=
createLogService
(
'
sharedprocess
'
,
environmentService
);
const
logService
=
create
Spd
LogService
(
'
sharedprocess
'
,
environmentService
);
process
.
once
(
'
exit
'
,
()
=>
logService
.
dispose
());
process
.
once
(
'
exit
'
,
()
=>
logService
.
dispose
());
logService
.
info
(
'
main
'
,
JSON
.
stringify
(
configuration
));
logService
.
info
(
'
main
'
,
JSON
.
stringify
(
configuration
));
...
...
src/vs/code/electron-main/main.ts
浏览文件 @
9914a95d
...
@@ -42,16 +42,16 @@ import { WorkspacesMainService } from 'vs/platform/workspaces/electron-main/work
...
@@ -42,16 +42,16 @@ import { WorkspacesMainService } from 'vs/platform/workspaces/electron-main/work
import
{
IWorkspacesMainService
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
IWorkspacesMainService
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
mnemonicButtonLabel
}
from
'
vs/base/common/labels
'
;
import
{
mnemonicButtonLabel
}
from
'
vs/base/common/labels
'
;
import
{
createLogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
create
Spd
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
printDiagnostics
}
from
'
vs/code/electron-main/diagnostics
'
;
import
{
printDiagnostics
}
from
'
vs/code/electron-main/diagnostics
'
;
import
{
BufferLogService
}
from
'
vs/platform/log/common/bufferLog
'
;
function
createServices
(
args
:
ParsedArgs
):
IInstantiationService
{
function
createServices
(
args
:
ParsedArgs
,
bufferLogService
:
BufferLogService
):
IInstantiationService
{
const
services
=
new
ServiceCollection
();
const
services
=
new
ServiceCollection
();
const
environmentService
=
new
EnvironmentService
(
args
,
process
.
execPath
);
const
environmentService
=
new
EnvironmentService
(
args
,
process
.
execPath
);
const
spdlogService
=
createLogService
(
'
main
'
,
environmentService
);
const
consoleLogService
=
new
ConsoleLogMainService
(
environmentService
);
const
consoleLogService
=
new
ConsoleLogMainService
(
environmentService
);
const
logService
=
new
MultiplexLogService
([
consoleLogService
,
spdl
ogService
]);
const
logService
=
new
MultiplexLogService
([
consoleLogService
,
bufferL
ogService
]);
process
.
once
(
'
exit
'
,
()
=>
logService
.
dispose
());
process
.
once
(
'
exit
'
,
()
=>
logService
.
dispose
());
...
@@ -284,7 +284,12 @@ function main() {
...
@@ -284,7 +284,12 @@ function main() {
return
;
return
;
}
}
const
instantiationService
=
createServices
(
args
);
// We need to buffer the spdlog logs until we are sure
// we are the only instance running, otherwise we'll have concurrent
// log file access on Windows
// https://github.com/Microsoft/vscode/issues/41218
const
bufferLogService
=
new
BufferLogService
();
const
instantiationService
=
createServices
(
args
,
bufferLogService
);
return
instantiationService
.
invokeFunction
(
accessor
=>
{
return
instantiationService
.
invokeFunction
(
accessor
=>
{
...
@@ -300,7 +305,10 @@ function main() {
...
@@ -300,7 +305,10 @@ function main() {
// Startup
// Startup
return
instantiationService
.
invokeFunction
(
a
=>
createPaths
(
a
.
get
(
IEnvironmentService
)))
return
instantiationService
.
invokeFunction
(
a
=>
createPaths
(
a
.
get
(
IEnvironmentService
)))
.
then
(()
=>
instantiationService
.
invokeFunction
(
setupIPC
))
.
then
(()
=>
instantiationService
.
invokeFunction
(
setupIPC
))
.
then
(
mainIpcServer
=>
instantiationService
.
createInstance
(
CodeApplication
,
mainIpcServer
,
instanceEnv
).
startup
());
.
then
(
mainIpcServer
=>
{
bufferLogService
.
logger
=
createSpdLogService
(
'
main
'
,
environmentService
);
return
instantiationService
.
createInstance
(
CodeApplication
,
mainIpcServer
,
instanceEnv
).
startup
();
});
}).
done
(
null
,
err
=>
instantiationService
.
invokeFunction
(
quit
,
err
));
}).
done
(
null
,
err
=>
instantiationService
.
invokeFunction
(
quit
,
err
));
}
}
...
...
src/vs/code/node/cliProcessMain.ts
浏览文件 @
9914a95d
...
@@ -35,7 +35,7 @@ import { ChoiceCliService } from 'vs/platform/message/node/messageCli';
...
@@ -35,7 +35,7 @@ import { ChoiceCliService } from 'vs/platform/message/node/messageCli';
import
{
getBaseLabel
}
from
'
vs/base/common/labels
'
;
import
{
getBaseLabel
}
from
'
vs/base/common/labels
'
;
import
{
IStateService
}
from
'
vs/platform/state/common/state
'
;
import
{
IStateService
}
from
'
vs/platform/state/common/state
'
;
import
{
StateService
}
from
'
vs/platform/state/node/stateService
'
;
import
{
StateService
}
from
'
vs/platform/state/node/stateService
'
;
import
{
createLogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
create
Spd
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
isPromiseCanceledError
}
from
'
vs/base/common/errors
'
;
import
{
isPromiseCanceledError
}
from
'
vs/base/common/errors
'
;
...
@@ -196,7 +196,7 @@ export function main(argv: ParsedArgs): TPromise<void> {
...
@@ -196,7 +196,7 @@ export function main(argv: ParsedArgs): TPromise<void> {
const
services
=
new
ServiceCollection
();
const
services
=
new
ServiceCollection
();
const
environmentService
=
new
EnvironmentService
(
argv
,
process
.
execPath
);
const
environmentService
=
new
EnvironmentService
(
argv
,
process
.
execPath
);
const
logService
=
createLogService
(
'
cli
'
,
environmentService
);
const
logService
=
create
Spd
LogService
(
'
cli
'
,
environmentService
);
process
.
once
(
'
exit
'
,
()
=>
logService
.
dispose
());
process
.
once
(
'
exit
'
,
()
=>
logService
.
dispose
());
logService
.
info
(
'
main
'
,
argv
);
logService
.
info
(
'
main
'
,
argv
);
...
...
src/vs/platform/log/common/bufferLog.ts
0 → 100644
浏览文件 @
9914a95d
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
ILogService
,
LogLevel
}
from
'
vs/platform/log/common/log
'
;
interface
ILog
{
level
:
LogLevel
;
args
:
IArguments
;
}
function
getLogFunction
(
logger
:
ILogService
,
level
:
LogLevel
):
Function
{
switch
(
level
)
{
case
LogLevel
.
Trace
:
return
logger
.
trace
;
case
LogLevel
.
Debug
:
return
logger
.
debug
;
case
LogLevel
.
Info
:
return
logger
.
info
;
case
LogLevel
.
Warning
:
return
logger
.
warn
;
case
LogLevel
.
Error
:
return
logger
.
error
;
case
LogLevel
.
Critical
:
return
logger
.
critical
;
default
:
throw
new
Error
(
'
Invalid log level
'
);
}
}
export
class
BufferLogService
implements
ILogService
{
_serviceBrand
:
any
;
private
buffer
:
ILog
[]
=
[];
private
_logger
:
ILogService
|
undefined
=
undefined
;
constructor
(
private
level
:
LogLevel
=
LogLevel
.
Error
)
{
}
set
logger
(
logger
:
ILogService
)
{
this
.
_logger
=
logger
;
for
(
const
{
level
,
args
}
of
this
.
buffer
)
{
const
fn
=
getLogFunction
(
logger
,
level
);
fn
.
apply
(
logger
,
args
);
}
this
.
buffer
=
[];
}
setLevel
(
logLevel
:
LogLevel
):
void
{
this
.
level
=
logLevel
;
}
getLevel
():
LogLevel
{
return
this
.
level
;
}
private
_log
(
level
:
LogLevel
,
args
:
IArguments
):
void
{
if
(
this
.
_logger
)
{
const
fn
=
getLogFunction
(
this
.
_logger
,
level
);
fn
.
apply
(
this
.
_logger
,
args
);
}
else
if
(
this
.
level
<
level
)
{
this
.
buffer
.
push
({
level
,
args
});
}
}
trace
():
void
{
this
.
_log
(
LogLevel
.
Trace
,
arguments
);
}
debug
():
void
{
this
.
_log
(
LogLevel
.
Debug
,
arguments
);
}
info
():
void
{
this
.
_log
(
LogLevel
.
Info
,
arguments
);
}
warn
():
void
{
this
.
_log
(
LogLevel
.
Warning
,
arguments
);
}
error
():
void
{
this
.
_log
(
LogLevel
.
Error
,
arguments
);
}
critical
():
void
{
this
.
_log
(
LogLevel
.
Critical
,
arguments
);
}
dispose
():
void
{
if
(
this
.
_logger
)
{
this
.
_logger
.
dispose
();
}
}
}
\ No newline at end of file
src/vs/platform/log/node/spdlogService.ts
浏览文件 @
9914a95d
...
@@ -10,7 +10,7 @@ import { ILogService, LogLevel, NullLogService } from 'vs/platform/log/common/lo
...
@@ -10,7 +10,7 @@ import { ILogService, LogLevel, NullLogService } from 'vs/platform/log/common/lo
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
RotatingLogger
,
setAsyncMode
}
from
'
spdlog
'
;
import
{
RotatingLogger
,
setAsyncMode
}
from
'
spdlog
'
;
export
function
createLogService
(
processName
:
string
,
environmentService
:
IEnvironmentService
,
logsSubfolder
?:
string
):
ILogService
{
export
function
create
Spd
LogService
(
processName
:
string
,
environmentService
:
IEnvironmentService
,
logsSubfolder
?:
string
):
ILogService
{
try
{
try
{
setAsyncMode
(
8192
,
2000
);
setAsyncMode
(
8192
,
2000
);
const
logsDirPath
=
logsSubfolder
?
path
.
join
(
environmentService
.
logsPath
,
logsSubfolder
)
:
environmentService
.
logsPath
;
const
logsDirPath
=
logsSubfolder
?
path
.
join
(
environmentService
.
logsPath
,
logsSubfolder
)
:
environmentService
.
logsPath
;
...
...
src/vs/workbench/api/node/extHostLogService.ts
浏览文件 @
9914a95d
...
@@ -11,7 +11,7 @@ import { mkdirp, dirExists } from 'vs/base/node/pfs';
...
@@ -11,7 +11,7 @@ import { mkdirp, dirExists } from 'vs/base/node/pfs';
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
LogLevel
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
LogLevel
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
createLogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
create
Spd
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
memoize
}
from
'
vs/base/common/decorators
'
;
import
{
memoize
}
from
'
vs/base/common/decorators
'
;
...
@@ -23,7 +23,7 @@ export class ExtHostLogService {
...
@@ -23,7 +23,7 @@ export class ExtHostLogService {
getExtLogger
(
extensionID
:
string
):
ExtHostLogger
{
getExtLogger
(
extensionID
:
string
):
ExtHostLogger
{
if
(
!
this
.
_loggers
.
has
(
extensionID
))
{
if
(
!
this
.
_loggers
.
has
(
extensionID
))
{
const
logService
=
createLogService
(
extensionID
,
this
.
_environmentService
,
extensionID
);
const
logService
=
create
Spd
LogService
(
extensionID
,
this
.
_environmentService
,
extensionID
);
const
logsDirPath
=
path
.
join
(
this
.
_environmentService
.
logsPath
,
extensionID
);
const
logsDirPath
=
path
.
join
(
this
.
_environmentService
.
logsPath
,
extensionID
);
this
.
_loggers
.
set
(
extensionID
,
new
ExtHostLogger
(
logService
,
logsDirPath
));
this
.
_loggers
.
set
(
extensionID
,
new
ExtHostLogger
(
logService
,
logsDirPath
));
}
}
...
...
src/vs/workbench/electron-browser/main.ts
浏览文件 @
9914a95d
...
@@ -40,7 +40,7 @@ import { URLChannelClient } from 'vs/platform/url/common/urlIpc';
...
@@ -40,7 +40,7 @@ import { URLChannelClient } from 'vs/platform/url/common/urlIpc';
import
{
IURLService
}
from
'
vs/platform/url/common/url
'
;
import
{
IURLService
}
from
'
vs/platform/url/common/url
'
;
import
{
WorkspacesChannelClient
}
from
'
vs/platform/workspaces/common/workspacesIpc
'
;
import
{
WorkspacesChannelClient
}
from
'
vs/platform/workspaces/common/workspacesIpc
'
;
import
{
IWorkspacesService
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
IWorkspacesService
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
createLogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
create
Spd
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
fs
=
require
(
'
fs
'
);
import
fs
=
require
(
'
fs
'
);
import
{
ConsoleLogService
,
MultiplexLogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ConsoleLogService
,
MultiplexLogService
}
from
'
vs/platform/log/common/log
'
;
...
@@ -73,7 +73,7 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise<void> {
...
@@ -73,7 +73,7 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise<void> {
const
mainServices
=
createMainProcessServices
(
mainProcessClient
,
configuration
);
const
mainServices
=
createMainProcessServices
(
mainProcessClient
,
configuration
);
const
environmentService
=
new
EnvironmentService
(
configuration
,
configuration
.
execPath
);
const
environmentService
=
new
EnvironmentService
(
configuration
,
configuration
.
execPath
);
const
spdlogService
=
createLogService
(
`renderer
${
configuration
.
windowId
}
`
,
environmentService
);
const
spdlogService
=
create
Spd
LogService
(
`renderer
${
configuration
.
windowId
}
`
,
environmentService
);
const
consoleLogService
=
new
ConsoleLogService
(
environmentService
);
const
consoleLogService
=
new
ConsoleLogService
(
environmentService
);
const
logService
=
new
MultiplexLogService
([
consoleLogService
,
spdlogService
]);
const
logService
=
new
MultiplexLogService
([
consoleLogService
,
spdlogService
]);
...
...
src/vs/workbench/node/extensionHostMain.ts
浏览文件 @
9914a95d
...
@@ -21,7 +21,7 @@ import * as watchdog from 'native-watchdog';
...
@@ -21,7 +21,7 @@ import * as watchdog from 'native-watchdog';
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
ExtensionActivatedByEvent
}
from
'
vs/workbench/api/node/extHostExtensionActivator
'
;
import
{
ExtensionActivatedByEvent
}
from
'
vs/workbench/api/node/extHostExtensionActivator
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
{
createLogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
create
Spd
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
IMessagePassingProtocol
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
IMessagePassingProtocol
}
from
'
vs/base/parts/ipc/common/ipc
'
;
...
@@ -92,7 +92,7 @@ export class ExtensionHostMain {
...
@@ -92,7 +92,7 @@ export class ExtensionHostMain {
const
rpcProtocol
=
new
RPCProtocol
(
protocol
);
const
rpcProtocol
=
new
RPCProtocol
(
protocol
);
const
extHostWorkspace
=
new
ExtHostWorkspace
(
rpcProtocol
,
initData
.
workspace
);
const
extHostWorkspace
=
new
ExtHostWorkspace
(
rpcProtocol
,
initData
.
workspace
);
const
environmentService
=
new
EnvironmentService
(
initData
.
args
,
initData
.
execPath
);
const
environmentService
=
new
EnvironmentService
(
initData
.
args
,
initData
.
execPath
);
this
.
_logService
=
createLogService
(
`exthost
${
initData
.
windowId
}
`
,
environmentService
);
this
.
_logService
=
create
Spd
LogService
(
`exthost
${
initData
.
windowId
}
`
,
environmentService
);
this
.
disposables
.
push
(
this
.
_logService
);
this
.
disposables
.
push
(
this
.
_logService
);
this
.
_logService
.
info
(
'
extension host started
'
);
this
.
_logService
.
info
(
'
extension host started
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录