Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
fd1c9a12
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fd1c9a12
编写于
12月 05, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#39659: Fallback to noop log service when spd log service is failed to create
上级
bf17a59c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
44 addition
and
39 deletion
+44
-39
src/vs/code/electron-browser/sharedProcessMain.ts
src/vs/code/electron-browser/sharedProcessMain.ts
+2
-2
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+19
-4
src/vs/code/node/cliProcessMain.ts
src/vs/code/node/cliProcessMain.ts
+3
-2
src/vs/platform/log/node/spdlogService.ts
src/vs/platform/log/node/spdlogService.ts
+16
-27
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/sharedProcessMain.ts
浏览文件 @
fd1c9a12
...
...
@@ -35,7 +35,7 @@ import { WindowsChannelClient } from 'vs/platform/windows/common/windowsIpc';
import
{
ipcRenderer
}
from
'
electron
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
createSharedProcessContributions
}
from
'
vs/code/electron-browser/contrib/contributions
'
;
import
{
Spd
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
create
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
ILogService
,
registerGlobalLogService
}
from
'
vs/platform/log/common/log
'
;
export
interface
ISharedProcessConfiguration
{
...
...
@@ -79,7 +79,7 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I
const
services
=
new
ServiceCollection
();
const
environmentService
=
new
EnvironmentService
(
initData
.
args
,
process
.
execPath
);
const
logService
=
new
Spd
LogService
(
'
sharedprocess
'
,
environmentService
);
const
logService
=
create
LogService
(
'
sharedprocess
'
,
environmentService
);
process
.
once
(
'
exit
'
,
()
=>
logService
.
dispose
());
registerGlobalLogService
(
logService
);
...
...
src/vs/code/electron-main/main.ts
浏览文件 @
fd1c9a12
...
...
@@ -9,8 +9,9 @@ import { app, dialog } from 'electron';
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
product
from
'
vs/platform/node/product
'
;
import
*
as
path
from
'
path
'
;
import
{
parseMainProcessArgv
}
from
'
vs/platform/environment/node/argv
'
;
import
{
mkdirp
}
from
'
vs/base/node/pfs
'
;
import
{
mkdirp
,
readdir
,
rimraf
}
from
'
vs/base/node/pfs
'
;
import
{
validatePaths
}
from
'
vs/code/node/paths
'
;
import
{
LifecycleService
,
ILifecycleService
}
from
'
vs/platform/lifecycle/electron-main/lifecycleMain
'
;
import
{
Server
,
serve
,
connect
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
...
...
@@ -41,14 +42,14 @@ import { WorkspacesMainService } from 'vs/platform/workspaces/electron-main/work
import
{
IWorkspacesMainService
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
mnemonicButtonLabel
}
from
'
vs/base/common/labels
'
;
import
{
Spd
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
create
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
printDiagnostics
}
from
'
vs/code/electron-main/diagnostics
'
;
function
createServices
(
args
:
ParsedArgs
):
IInstantiationService
{
const
services
=
new
ServiceCollection
();
const
environmentService
=
new
EnvironmentService
(
args
,
process
.
execPath
);
const
spdlogService
=
new
Spd
LogService
(
'
main
'
,
environmentService
);
const
spdlogService
=
create
LogService
(
'
main
'
,
environmentService
);
const
consoleLogService
=
new
ConsoleLogMainService
(
environmentService
);
const
logService
=
new
MultiplexLogService
([
consoleLogService
,
spdlogService
]);
...
...
@@ -56,7 +57,7 @@ function createServices(args: ParsedArgs): IInstantiationService {
process
.
once
(
'
exit
'
,
()
=>
logService
.
dispose
());
// Eventually cleanup
setTimeout
(()
=>
spdlogService
.
cleanup
(
).
then
(
null
,
err
=>
console
.
error
(
err
)),
10000
);
setTimeout
(()
=>
cleanupOlderLogs
(
environmentService
).
then
(
null
,
err
=>
console
.
error
(
err
)),
10000
);
services
.
set
(
IEnvironmentService
,
environmentService
);
services
.
set
(
ILogService
,
logService
);
...
...
@@ -72,6 +73,20 @@ function createServices(args: ParsedArgs): IInstantiationService {
return
new
InstantiationService
(
services
,
true
);
}
/**
* Cleans up older logs, while keeping the 10 most recent ones.
*/
async
function
cleanupOlderLogs
(
environmentService
:
EnvironmentService
):
TPromise
<
void
>
{
const
currentLog
=
path
.
basename
(
environmentService
.
logsPath
);
const
logsRoot
=
path
.
dirname
(
environmentService
.
logsPath
);
const
children
=
await
readdir
(
logsRoot
);
const
allSessions
=
children
.
filter
(
name
=>
/^
\d{8}
T
\d{6}
$/
.
test
(
name
));
const
oldSessions
=
allSessions
.
sort
().
filter
((
d
,
i
)
=>
d
!==
currentLog
);
const
toDelete
=
oldSessions
.
slice
(
0
,
Math
.
max
(
0
,
oldSessions
.
length
-
9
));
await
TPromise
.
join
(
toDelete
.
map
(
name
=>
rimraf
(
path
.
join
(
logsRoot
,
name
))));
}
function
createPaths
(
environmentService
:
IEnvironmentService
):
TPromise
<
any
>
{
const
paths
=
[
environmentService
.
appSettingsHome
,
...
...
src/vs/code/node/cliProcessMain.ts
浏览文件 @
fd1c9a12
...
...
@@ -35,7 +35,7 @@ import { ChoiceCliService } from 'vs/platform/message/node/messageCli';
import
{
getBaseLabel
}
from
'
vs/base/common/labels
'
;
import
{
IStateService
}
from
'
vs/platform/state/common/state
'
;
import
{
StateService
}
from
'
vs/platform/state/node/stateService
'
;
import
{
Spd
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
create
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
registerGlobalLogService
,
ILogService
}
from
'
vs/platform/log/common/log
'
;
const
notFound
=
(
id
:
string
)
=>
localize
(
'
notFound
'
,
"
Extension '{0}' not found.
"
,
id
);
...
...
@@ -179,7 +179,8 @@ export function main(argv: ParsedArgs): TPromise<void> {
const
services
=
new
ServiceCollection
();
const
environmentService
=
new
EnvironmentService
(
argv
,
process
.
execPath
);
const
logService
=
new
SpdLogService
(
'
cli
'
,
environmentService
);
const
logService
=
createLogService
(
'
cli
'
,
environmentService
);
process
.
once
(
'
exit
'
,
()
=>
logService
.
dispose
());
registerGlobalLogService
(
logService
);
logService
.
info
(
'
main
'
,
argv
);
...
...
src/vs/platform/log/node/spdlogService.ts
浏览文件 @
fd1c9a12
...
...
@@ -6,44 +6,33 @@
'
use strict
'
;
import
*
as
path
from
'
path
'
;
import
{
ILogService
,
LogLevel
}
from
'
vs/platform/log/common/log
'
;
import
{
ILogService
,
LogLevel
,
NoopLogService
}
from
'
vs/platform/log/common/log
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
RotatingLogger
,
setAsyncMode
}
from
'
spdlog
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
readdir
,
rimraf
}
from
'
vs/base/node/pfs
'
;
export
class
SpdLogService
implements
ILogService
{
export
function
createLogService
(
processName
:
string
,
environmentService
:
IEnvironmentService
):
ILogService
{
try
{
setAsyncMode
(
8192
,
2000
);
const
logfilePath
=
path
.
join
(
environmentService
.
logsPath
,
`
${
processName
}
.log`
);
const
logger
=
new
RotatingLogger
(
processName
,
logfilePath
,
1024
*
1024
*
5
,
6
);
return
new
SpdLogService
(
logger
,
environmentService
.
logLevel
);
}
catch
(
e
)
{
console
.
error
(
e
);
}
return
new
NoopLogService
();
}
class
SpdLogService
implements
ILogService
{
_serviceBrand
:
any
;
private
level
:
LogLevel
=
LogLevel
.
Error
;
private
logger
:
RotatingLogger
;
private
disposables
:
IDisposable
[]
=
[];
constructor
(
pr
ocessName
:
string
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
pr
ivate
readonly
logger
:
RotatingLogger
,
private
level
:
LogLevel
=
LogLevel
.
Error
)
{
setAsyncMode
(
8192
,
2000
);
const
logfilePath
=
path
.
join
(
environmentService
.
logsPath
,
`
${
processName
}
.log`
);
this
.
logger
=
new
RotatingLogger
(
processName
,
logfilePath
,
1024
*
1024
*
5
,
6
);
this
.
setLevel
(
environmentService
.
logLevel
);
}
/**
* Cleans up older logs, while keeping the 10 most recent ones.
*/
async
cleanup
():
TPromise
<
void
>
{
const
currentLog
=
path
.
basename
(
this
.
environmentService
.
logsPath
);
const
logsRoot
=
path
.
dirname
(
this
.
environmentService
.
logsPath
);
const
children
=
await
readdir
(
logsRoot
);
const
allSessions
=
children
.
filter
(
name
=>
/^
\d{8}
T
\d{6}
$/
.
test
(
name
));
const
oldSessions
=
allSessions
.
sort
().
filter
((
d
,
i
)
=>
d
!==
currentLog
);
const
toDelete
=
oldSessions
.
slice
(
0
,
Math
.
max
(
0
,
oldSessions
.
length
-
9
));
await
TPromise
.
join
(
toDelete
.
map
(
name
=>
rimraf
(
path
.
join
(
logsRoot
,
name
))));
}
setLevel
(
logLevel
:
LogLevel
):
void
{
...
...
src/vs/workbench/electron-browser/main.ts
浏览文件 @
fd1c9a12
...
...
@@ -39,7 +39,7 @@ import { URLChannelClient } from 'vs/platform/url/common/urlIpc';
import
{
IURLService
}
from
'
vs/platform/url/common/url
'
;
import
{
WorkspacesChannelClient
}
from
'
vs/platform/workspaces/common/workspacesIpc
'
;
import
{
IWorkspacesService
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
Spd
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
create
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
fs
=
require
(
'
fs
'
);
import
{
registerGlobalLogService
}
from
'
vs/platform/log/common/log
'
;
...
...
@@ -74,7 +74,7 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise<void> {
const
mainServices
=
createMainProcessServices
(
mainProcessClient
);
const
environmentService
=
new
EnvironmentService
(
configuration
,
configuration
.
execPath
);
const
logService
=
new
Spd
LogService
(
`renderer
${
currentWindowId
}
`
,
environmentService
);
const
logService
=
create
LogService
(
`renderer
${
currentWindowId
}
`
,
environmentService
);
registerGlobalLogService
(
logService
);
logService
.
info
(
'
openWorkbench
'
,
JSON
.
stringify
(
configuration
));
...
...
src/vs/workbench/node/extensionHostMain.ts
浏览文件 @
fd1c9a12
...
...
@@ -23,7 +23,7 @@ import * as watchdog from 'native-watchdog';
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
ExtensionActivatedByEvent
}
from
'
vs/workbench/api/node/extHostExtensionActivator
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
{
Spd
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
create
LogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
registerGlobalLogService
}
from
'
vs/platform/log/common/log
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
...
...
@@ -90,7 +90,7 @@ export class ExtensionHostMain {
const
threadService
=
new
ExtHostThreadService
(
rpcProtocol
);
const
extHostWorkspace
=
new
ExtHostWorkspace
(
threadService
,
initData
.
workspace
);
const
environmentService
=
new
EnvironmentService
(
initData
.
args
,
initData
.
execPath
);
const
logService
=
new
Spd
LogService
(
`exthost
${
initData
.
windowId
}
`
,
environmentService
);
const
logService
=
create
LogService
(
`exthost
${
initData
.
windowId
}
`
,
environmentService
);
registerGlobalLogService
(
logService
);
this
.
disposables
.
push
(
logService
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录