Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
04a3f959
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,发现更多精彩内容 >>
提交
04a3f959
编写于
9月 04, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve ext host logging
上级
d33f082f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
67 addition
and
17 deletion
+67
-17
src/vs/workbench/services/extensions/electron-browser/extensionService.ts
.../services/extensions/electron-browser/extensionService.ts
+46
-5
src/vs/workbench/services/extensions/node/rpcProtocol.ts
src/vs/workbench/services/extensions/node/rpcProtocol.ts
+21
-12
未找到文件。
src/vs/workbench/services/extensions/electron-browser/extensionService.ts
浏览文件 @
04a3f959
...
...
@@ -39,7 +39,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import
{
ExtensionHostProfiler
}
from
'
vs/workbench/services/extensions/electron-browser/extensionHostProfiler
'
;
import
product
from
'
vs/platform/node/product
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
RPCProtocol
,
IRPCProtocolLogger
}
from
'
vs/workbench/services/extensions/node/rpcProtocol
'
;
import
{
RPCProtocol
,
IRPCProtocolLogger
,
RequestInitiator
}
from
'
vs/workbench/services/extensions/node/rpcProtocol
'
;
import
{
INotificationService
,
Severity
}
from
'
vs/platform/notification/common/notification
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
...
...
@@ -48,6 +48,7 @@ import { isEqualOrParent } from 'vs/base/common/resources';
// Enable to see detailed message communication between window and extension host
const
LOG_EXTENSION_HOST_COMMUNICATION
=
false
;
const
LOG_USE_COLORS
=
true
;
let
_SystemExtensionsRoot
:
string
=
null
;
function
getSystemExtensionsRoot
():
string
{
...
...
@@ -955,19 +956,59 @@ export class ExtensionService extends Disposable implements IExtensionService {
}
}
const
colorTables
=
[
[
'
#2977B1
'
,
'
#FC802D
'
,
'
#34A13A
'
,
'
#D3282F
'
,
'
#9366BA
'
],
[
'
#8B564C
'
,
'
#E177C0
'
,
'
#7F7F7F
'
,
'
#BBBE3D
'
,
'
#2EBECD
'
]
];
function
prettyWithoutArrays
(
data
:
any
):
any
{
if
(
Array
.
isArray
(
data
))
{
return
data
;
}
if
(
data
&&
typeof
data
===
'
object
'
&&
typeof
data
.
toString
===
'
function
'
)
{
let
result
=
data
.
toString
();
if
(
result
!==
'
[object Object]
'
)
{
return
result
;
}
}
return
data
;
}
function
pretty
(
data
:
any
):
any
{
if
(
Array
.
isArray
(
data
))
{
return
data
.
map
(
prettyWithoutArrays
);
}
return
prettyWithoutArrays
(
data
);
}
class
RPCLogger
implements
IRPCProtocolLogger
{
private
_totalIncoming
=
0
;
private
_totalOutgoing
=
0
;
logIncoming
(
msgLength
:
number
,
str
:
string
,
data
?:
any
):
void
{
private
_log
(
direction
:
string
,
totalLength
,
msgLength
:
number
,
req
:
number
,
initiator
:
RequestInitiator
,
str
:
string
,
data
:
any
):
void
{
data
=
pretty
(
data
);
const
colorTable
=
colorTables
[
initiator
];
const
color
=
LOG_USE_COLORS
?
colorTable
[
req
%
colorTable
.
length
]
:
'
#000000
'
;
let
args
=
[
`%c[
${
direction
}
]%c[
${
strings
.
pad
(
totalLength
,
7
,
'
'
)}
]%c[len:
${
strings
.
pad
(
msgLength
,
5
,
'
'
)}
]%c
${
strings
.
pad
(
req
,
5
,
'
'
)}
-
${
str
}
`
,
'
color: darkgreen
'
,
'
color: grey
'
,
'
color: grey
'
,
`color:
${
color
}
`
];
if
(
/
\(
$/
.
test
(
str
))
{
args
=
args
.
concat
(
data
);
args
.
push
(
'
)
'
);
}
else
{
args
.
push
(
data
);
}
console
.
log
.
apply
(
console
,
args
);
}
logIncoming
(
msgLength
:
number
,
req
:
number
,
initiator
:
RequestInitiator
,
str
:
string
,
data
?:
any
):
void
{
this
.
_totalIncoming
+=
msgLength
;
console
.
log
(
`%c[Extension \u2192 Window]%c[
${
strings
.
pad
(
this
.
_totalIncoming
,
7
,
'
'
)}
]%c[len:
${
strings
.
pad
(
msgLength
,
5
,
'
'
)}
]`
,
'
color: darkgreen
'
,
'
color: grey
'
,
'
color: grey
'
,
str
,
data
);
this
.
_log
(
'
Ext
\
u2192 Win
'
,
this
.
_totalIncoming
,
msgLength
,
req
,
initiator
,
str
,
data
);
}
logOutgoing
(
msgLength
:
number
,
str
:
string
,
data
?:
any
):
void
{
logOutgoing
(
msgLength
:
number
,
req
:
number
,
initiator
:
RequestInitiator
,
str
:
string
,
data
?:
any
):
void
{
this
.
_totalOutgoing
+=
msgLength
;
console
.
log
(
`%c[Window \u2192 Extension]%c[
${
strings
.
pad
(
this
.
_totalOutgoing
,
7
,
'
'
)}
]%c[len:
${
strings
.
pad
(
msgLength
,
5
,
'
'
)}
]`
,
'
color: darkgreen
'
,
'
color: grey
'
,
'
color: grey
'
,
str
,
data
);
this
.
_log
(
'
Win
\
u2192 Ext
'
,
this
.
_totalOutgoing
,
msgLength
,
req
,
initiator
,
str
,
data
);
}
}
...
...
src/vs/workbench/services/extensions/node/rpcProtocol.ts
浏览文件 @
04a3f959
...
...
@@ -85,9 +85,14 @@ function transformIncomingURIs(obj: any, transformer: IURITransformer): any {
return
result
;
}
export
const
enum
RequestInitiator
{
LocalSide
=
0
,
OtherSide
=
1
}
export
interface
IRPCProtocolLogger
{
logIncoming
(
msgLength
:
number
,
str
:
string
,
data
?:
any
):
void
;
logOutgoing
(
msgLength
:
number
,
str
:
string
,
data
?:
any
):
void
;
logIncoming
(
msgLength
:
number
,
req
:
number
,
initiator
:
RequestInitiator
,
str
:
string
,
data
?:
any
):
void
;
logOutgoing
(
msgLength
:
number
,
req
:
number
,
initiator
:
RequestInitiator
,
str
:
string
,
data
?:
any
):
void
;
}
export
class
RPCProtocol
implements
IRPCProtocol
{
...
...
@@ -225,11 +230,11 @@ export class RPCProtocol implements IRPCProtocol {
if
(
this
.
_uriTransformer
)
{
err
=
transformIncomingURIs
(
err
,
this
.
_uriTransformer
);
}
this
.
_receiveReplyErr
(
req
,
err
);
this
.
_receiveReplyErr
(
msgLength
,
req
,
err
);
break
;
}
case
MessageType
.
ReplyErrEmpty
:
{
this
.
_receiveReplyErr
(
req
,
undefined
);
this
.
_receiveReplyErr
(
msgLength
,
req
,
undefined
);
break
;
}
}
...
...
@@ -237,7 +242,7 @@ export class RPCProtocol implements IRPCProtocol {
private
_receiveRequest
(
msgLength
:
number
,
req
:
number
,
rpcId
:
number
,
method
:
string
,
args
:
any
[]):
void
{
if
(
this
.
_logger
)
{
this
.
_logger
.
logIncoming
(
msgLength
,
`receiveRequest
${
req
}
,
${
getStringIdentifierForProxy
(
rpcId
)}
.
${
method
}
:
`
,
args
);
this
.
_logger
.
logIncoming
(
msgLength
,
req
,
RequestInitiator
.
OtherSide
,
`receiveRequest
${
getStringIdentifierForProxy
(
rpcId
)}
.
${
method
}
(
`
,
args
);
}
const
callId
=
String
(
req
);
...
...
@@ -250,14 +255,14 @@ export class RPCProtocol implements IRPCProtocol {
}
const
msg
=
MessageIO
.
serializeReplyOK
(
req
,
r
);
if
(
this
.
_logger
)
{
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
`replyOK
${
req
}
:`
,
r
);
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
req
,
RequestInitiator
.
OtherSide
,
`reply
:`
,
r
);
}
this
.
_protocol
.
send
(
msg
);
},
(
err
)
=>
{
delete
this
.
_invokedHandlers
[
callId
];
const
msg
=
MessageIO
.
serializeReplyErr
(
req
,
err
);
if
(
this
.
_logger
)
{
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
`replyErr
${
req
}
:`
,
err
);
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
req
,
RequestInitiator
.
OtherSide
,
`replyErr
:`
,
err
);
}
this
.
_protocol
.
send
(
msg
);
});
...
...
@@ -265,7 +270,7 @@ export class RPCProtocol implements IRPCProtocol {
private
_receiveCancel
(
msgLength
:
number
,
req
:
number
):
void
{
if
(
this
.
_logger
)
{
this
.
_logger
.
logIncoming
(
msgLength
,
`receiveCancel
${
req
}
`
);
this
.
_logger
.
logIncoming
(
msgLength
,
req
,
RequestInitiator
.
OtherSide
,
`receiveCancel
`
);
}
const
callId
=
String
(
req
);
if
(
this
.
_invokedHandlers
[
callId
])
{
...
...
@@ -275,7 +280,7 @@ export class RPCProtocol implements IRPCProtocol {
private
_receiveReply
(
msgLength
:
number
,
req
:
number
,
value
:
any
):
void
{
if
(
this
.
_logger
)
{
this
.
_logger
.
logIncoming
(
msgLength
,
`receiveReply
${
req
}
:`
,
value
);
this
.
_logger
.
logIncoming
(
msgLength
,
req
,
RequestInitiator
.
LocalSide
,
`receiveReply
:`
,
value
);
}
const
callId
=
String
(
req
);
if
(
!
this
.
_pendingRPCReplies
.
hasOwnProperty
(
callId
))
{
...
...
@@ -288,7 +293,11 @@ export class RPCProtocol implements IRPCProtocol {
pendingReply
.
resolveOk
(
value
);
}
private
_receiveReplyErr
(
req
:
number
,
value
:
any
):
void
{
private
_receiveReplyErr
(
msgLength
:
number
,
req
:
number
,
value
:
any
):
void
{
if
(
this
.
_logger
)
{
this
.
_logger
.
logIncoming
(
msgLength
,
req
,
RequestInitiator
.
LocalSide
,
`receiveReplyErr:`
,
value
);
}
const
callId
=
String
(
req
);
if
(
!
this
.
_pendingRPCReplies
.
hasOwnProperty
(
callId
))
{
return
;
...
...
@@ -337,7 +346,7 @@ export class RPCProtocol implements IRPCProtocol {
const
result
=
new
LazyPromise
(()
=>
{
const
msg
=
MessageIO
.
serializeCancel
(
req
);
if
(
this
.
_logger
)
{
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
`cancel
${
req
}
`
);
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
req
,
RequestInitiator
.
LocalSide
,
`cancel
`
);
}
this
.
_protocol
.
send
(
MessageIO
.
serializeCancel
(
req
));
});
...
...
@@ -348,7 +357,7 @@ export class RPCProtocol implements IRPCProtocol {
}
const
msg
=
MessageIO
.
serializeRequest
(
req
,
rpcId
,
methodName
,
args
);
if
(
this
.
_logger
)
{
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
`request
${
req
}
:
${
getStringIdentifierForProxy
(
rpcId
)}
.
${
methodName
}
:
`
,
args
);
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
req
,
RequestInitiator
.
LocalSide
,
`request:
${
getStringIdentifierForProxy
(
rpcId
)}
.
${
methodName
}
(
`
,
args
);
}
this
.
_protocol
.
send
(
msg
);
return
result
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录