Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
43aa378a
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,发现更多精彩内容 >>
提交
43aa378a
编写于
8月 21, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better extension host logging
上级
010a45cc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
39 deletion
+66
-39
src/vs/platform/log/common/fileLogService.ts
src/vs/platform/log/common/fileLogService.ts
+4
-0
src/vs/workbench/api/browser/mainThreadLogService.ts
src/vs/workbench/api/browser/mainThreadLogService.ts
+36
-10
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+5
-0
src/vs/workbench/api/worker/extHostLogService.ts
src/vs/workbench/api/worker/extHostLogService.ts
+19
-28
src/vs/workbench/services/extensions/browser/extensionService.ts
...workbench/services/extensions/browser/extensionService.ts
+2
-1
未找到文件。
src/vs/platform/log/common/fileLogService.ts
浏览文件 @
43aa378a
...
...
@@ -74,6 +74,10 @@ export class FileLogService extends AbstractLogService implements ILogService {
return
this
.
queue
.
queue
(()
=>
Promise
.
resolve
());
}
log
(
level
:
LogLevel
,
args
:
any
[]):
void
{
this
.
_log
(
level
,
this
.
format
(
args
));
}
private
_log
(
level
:
LogLevel
,
message
:
string
):
void
{
this
.
queue
.
queue
(
async
()
=>
{
let
content
=
await
this
.
loadContent
();
...
...
src/vs/workbench/api/browser/mainThreadLogService.ts
浏览文件 @
43aa378a
...
...
@@ -3,20 +3,46 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
extHostCustomer
}
from
'
vs/workbench/api/common/extHostCustomers
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IExtHostContext
,
ExtHostContext
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/common/extHostCustomers
'
;
import
{
ILogService
,
LogLevel
}
from
'
vs/platform/log/common/log
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IExtHostContext
,
ExtHostContext
,
MainThreadLogShape
,
MainContext
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
UriComponents
,
URI
}
from
'
vs/base/common/uri
'
;
import
{
FileLogService
}
from
'
vs/platform/log/common/fileLogService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
basename
}
from
'
vs/base/common/path
'
;
@
extHostCustomer
export
class
MainThreadLogService
extends
Disposable
{
@
extHostNamedCustomer
(
MainContext
.
MainThreadLog
)
export
class
MainThreadLogService
implements
MainThreadLogShape
{
private
readonly
_loggers
=
new
Map
<
string
,
FileLogService
>
();
private
readonly
_logListener
:
IDisposable
;
constructor
(
extHostContext
:
IExtHostContext
,
@
ILogService
logService
:
ILogService
,
@
ILogService
private
readonly
_logService
:
ILogService
,
@
IInstantiationService
private
readonly
_instaService
:
IInstantiationService
,
)
{
super
();
this
.
_register
(
logService
.
onDidChangeLogLevel
(
level
=>
extHostContext
.
getProxy
(
ExtHostContext
.
ExtHostLogService
).
$setLevel
(
level
)));
const
proxy
=
extHostContext
.
getProxy
(
ExtHostContext
.
ExtHostLogService
);
this
.
_logListener
=
_logService
.
onDidChangeLogLevel
(
level
=>
{
proxy
.
$setLevel
(
level
);
this
.
_loggers
.
forEach
(
value
=>
value
.
setLevel
(
level
));
});
}
dispose
():
void
{
this
.
_logListener
.
dispose
();
this
.
_loggers
.
forEach
(
value
=>
value
.
dispose
());
this
.
_loggers
.
clear
();
}
}
\ No newline at end of file
$log
(
file
:
UriComponents
,
level
:
LogLevel
,
message
:
any
[]):
void
{
const
uri
=
URI
.
revive
(
file
);
let
logger
=
this
.
_loggers
.
get
(
uri
.
toString
());
if
(
!
logger
)
{
logger
=
this
.
_instaService
.
createInstance
(
FileLogService
,
basename
(
file
.
path
),
URI
.
revive
(
file
),
this
.
_logService
.
getLevel
());
this
.
_loggers
.
set
(
uri
.
toString
(),
logger
);
}
logger
.
log
(
level
,
message
);
}
}
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
43aa378a
...
...
@@ -1284,6 +1284,10 @@ export interface ExtHostLogServiceShape {
$setLevel
(
level
:
LogLevel
):
void
;
}
export
interface
MainThreadLogShape
{
$log
(
file
:
UriComponents
,
level
:
LogLevel
,
args
:
any
[]):
void
;
}
export
interface
ExtHostOutputServiceShape
{
$setVisibleChannel
(
channelId
:
string
|
null
):
void
;
}
...
...
@@ -1326,6 +1330,7 @@ export const MainContext = {
MainThreadKeytar
:
createMainId
<
MainThreadKeytarShape
>
(
'
MainThreadKeytar
'
),
MainThreadLanguageFeatures
:
createMainId
<
MainThreadLanguageFeaturesShape
>
(
'
MainThreadLanguageFeatures
'
),
MainThreadLanguages
:
createMainId
<
MainThreadLanguagesShape
>
(
'
MainThreadLanguages
'
),
MainThreadLog
:
createMainId
<
MainThreadLogShape
>
(
'
MainThread
'
),
MainThreadMessageService
:
createMainId
<
MainThreadMessageServiceShape
>
(
'
MainThreadMessageService
'
),
MainThreadOutputService
:
createMainId
<
MainThreadOutputServiceShape
>
(
'
MainThreadOutputService
'
),
MainThreadProgress
:
createMainId
<
MainThreadProgressShape
>
(
'
MainThreadProgress
'
),
...
...
src/vs/workbench/api/worker/extHostLogService.ts
浏览文件 @
43aa378a
...
...
@@ -4,24 +4,33 @@
*--------------------------------------------------------------------------------------------*/
import
{
ILogService
,
LogLevel
,
AbstractLogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ExtHostLogServiceShape
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostLogServiceShape
,
MainThreadLogShape
,
MainContext
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
IExtHostInitDataService
}
from
'
vs/workbench/api/common/extHostInitDataService
'
;
import
{
IExtHostOutputService
}
from
'
vs/workbench/api/common/extHostOutput
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
IExtHostRpcService
}
from
'
vs/workbench/api/common/extHostRpcService
'
;
import
{
joinPath
}
from
'
vs/base/common/resources
'
;
import
{
ExtensionHostLogFileName
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
localize
}
from
'
vs/nls
'
;
export
class
ExtHostLogService
extends
AbstractLogService
implements
ILogService
,
ExtHostLogServiceShape
{
_serviceBrand
:
any
;
private
readonly
_logChannel
:
vscode
.
OutputChannel
;
private
readonly
_proxy
:
MainThreadLogShape
;
private
readonly
_logFile
:
UriComponents
;
constructor
(
@
IExtHostRpcService
rpc
:
IExtHostRpcService
,
@
IExtHostInitDataService
initData
:
IExtHostInitDataService
,
@
IExtHostOutputService
extHostOutputService
:
IExtHostOutputService
)
{
super
();
const
logFile
=
joinPath
(
initData
.
logsLocation
,
`
${
ExtensionHostLogFileName
}
.log`
);
this
.
_proxy
=
rpc
.
getProxy
(
MainContext
.
MainThreadLog
);
this
.
_logFile
=
logFile
.
toJSON
();
this
.
setLevel
(
initData
.
logLevel
);
this
.
_logChannel
=
extHostOutputService
.
createOutputChannel
(
'
Log (Worker Extension Host)
'
);
extHostOutputService
.
createOutputChannelFromLogFile
(
localize
(
'
name
'
,
"
Worker Extension Host
"
),
logFile
);
}
$setLevel
(
level
:
LogLevel
):
void
{
...
...
@@ -30,55 +39,37 @@ export class ExtHostLogService extends AbstractLogService implements ILogService
trace
(
_message
:
string
,
...
_args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Trace
)
{
this
.
_
logChannel
.
appendLine
(
this
.
_format
(
arguments
));
this
.
_
proxy
.
$log
(
this
.
_logFile
,
LogLevel
.
Trace
,
Array
.
from
(
arguments
));
}
}
debug
(
_message
:
string
,
...
_args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Debug
)
{
this
.
_
logChannel
.
appendLine
(
this
.
_format
(
arguments
));
this
.
_
proxy
.
$log
(
this
.
_logFile
,
LogLevel
.
Debug
,
Array
.
from
(
arguments
));
}
}
info
(
_message
:
string
,
...
_args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Info
)
{
this
.
_
logChannel
.
appendLine
(
this
.
_format
(
arguments
));
this
.
_
proxy
.
$log
(
this
.
_logFile
,
LogLevel
.
Info
,
Array
.
from
(
arguments
));
}
}
warn
(
_message
:
string
,
...
_args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Warning
)
{
this
.
_
logChannel
.
appendLine
(
this
.
_format
(
arguments
));
this
.
_
proxy
.
$log
(
this
.
_logFile
,
LogLevel
.
Warning
,
Array
.
from
(
arguments
));
}
}
error
(
_message
:
string
|
Error
,
...
_args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Error
)
{
this
.
_
logChannel
.
appendLine
(
this
.
_format
(
arguments
));
this
.
_
proxy
.
$log
(
this
.
_logFile
,
LogLevel
.
Error
,
Array
.
from
(
arguments
));
}
}
critical
(
_message
:
string
|
Error
,
...
_args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Critical
)
{
this
.
_
logChannel
.
appendLine
(
String
(
arguments
));
this
.
_
proxy
.
$log
(
this
.
_logFile
,
LogLevel
.
Critical
,
Array
.
from
(
arguments
));
}
}
private
_format
(
args
:
any
):
string
{
let
result
=
''
;
for
(
let
i
=
0
;
i
<
args
.
length
;
i
++
)
{
let
a
=
args
[
i
];
if
(
typeof
a
===
'
object
'
)
{
try
{
a
=
JSON
.
stringify
(
a
);
}
catch
(
e
)
{
}
}
result
+=
(
i
>
0
?
'
'
:
''
)
+
a
;
}
return
result
;
}
}
src/vs/workbench/services/extensions/browser/extensionService.ts
浏览文件 @
43aa378a
...
...
@@ -28,6 +28,7 @@ import { Schemas } from 'vs/base/common/network';
import
{
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
IStaticExtensionsService
}
from
'
vs/workbench/services/extensions/common/staticExtensions
'
;
import
{
DeltaExtensionsResult
}
from
'
vs/workbench/services/extensions/common/extensionDescriptionRegistry
'
;
import
{
INMEMORY_LOG_SCHEME
}
from
'
vs/workbench/services/log/common/inMemoryLogProvider
'
;
export
class
ExtensionService
extends
AbstractExtensionService
implements
IExtensionService
{
...
...
@@ -86,7 +87,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
const
result
:
ExtensionHostProcessManager
[]
=
[];
const
webExtensions
=
this
.
getExtensions
().
then
(
extensions
=>
extensions
.
filter
(
ext
=>
isWebExtension
(
ext
,
this
.
_configService
)));
const
webHostProcessWorker
=
this
.
_instantiationService
.
createInstance
(
WebWorkerExtensionHostStarter
,
true
,
webExtensions
,
URI
.
parse
(
'
empty:value
'
));
//todo@joh
const
webHostProcessWorker
=
this
.
_instantiationService
.
createInstance
(
WebWorkerExtensionHostStarter
,
true
,
webExtensions
,
URI
.
from
({
scheme
:
INMEMORY_LOG_SCHEME
,
path
:
'
/
'
}));
const
webHostProcessManager
=
this
.
_instantiationService
.
createInstance
(
ExtensionHostProcessManager
,
false
,
webHostProcessWorker
,
null
,
initialActivationEvents
);
result
.
push
(
webHostProcessManager
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录