Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
315cce83
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
315cce83
编写于
8月 17, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "remove proposed Logger-api, #43275"
This reverts commit
1c72ab24
.
上级
e8772480
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
73 addition
and
4 deletion
+73
-4
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+16
-0
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-4
src/vs/workbench/api/node/extHostExtensionActivator.ts
src/vs/workbench/api/node/extHostExtensionActivator.ts
+2
-0
src/vs/workbench/api/node/extHostExtensionService.ts
src/vs/workbench/api/node/extHostExtensionService.ts
+4
-0
src/vs/workbench/api/node/extHostLogService.ts
src/vs/workbench/api/node/extHostLogService.ts
+50
-0
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
315cce83
...
...
@@ -434,7 +434,23 @@ declare module 'vscode' {
Off
=
7
}
/**
* A logger for writing to an extension's log file, and accessing its dedicated log directory.
*/
export
interface
Logger
{
trace
(
message
:
string
,
...
args
:
any
[]):
void
;
debug
(
message
:
string
,
...
args
:
any
[]):
void
;
info
(
message
:
string
,
...
args
:
any
[]):
void
;
warn
(
message
:
string
,
...
args
:
any
[]):
void
;
error
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
;
critical
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
;
}
export
interface
ExtensionContext
{
/**
* This extension's logger
*/
logger
:
Logger
;
/**
* Path where an extension can write log files.
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
315cce83
...
...
@@ -227,10 +227,7 @@ export function createApiFactory(
get
language
()
{
return
platform
.
language
;
},
get
appName
()
{
return
product
.
nameLong
;
},
get
appRoot
()
{
return
initData
.
environment
.
appRoot
;
},
get
logLevel
()
{
checkProposedApiEnabled
(
extension
);
return
extHostLogService
.
getLevel
();
}
get
logLevel
()
{
return
extHostLogService
.
getLevel
();
}
});
// namespace: extensions
...
...
src/vs/workbench/api/node/extHostExtensionActivator.ts
浏览文件 @
315cce83
...
...
@@ -10,6 +10,7 @@ import Severity from 'vs/base/common/severity';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ExtensionDescriptionRegistry
}
from
'
vs/workbench/services/extensions/node/extensionDescriptionRegistry
'
;
import
{
IExtensionDescription
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
ExtHostLogger
}
from
'
vs/workbench/api/node/extHostLogService
'
;
const
hasOwnProperty
=
Object
.
hasOwnProperty
;
const
NO_OP_VOID_PROMISE
=
TPromise
.
wrap
<
void
>
(
void
0
);
...
...
@@ -26,6 +27,7 @@ export interface IExtensionContext {
extensionPath
:
string
;
storagePath
:
string
;
asAbsolutePath
(
relativePath
:
string
):
string
;
logger
:
ExtHostLogger
;
readonly
logDirectory
:
string
;
readonly
logPath
:
string
;
}
...
...
src/vs/workbench/api/node/extHostExtensionService.ts
浏览文件 @
315cce83
...
...
@@ -361,6 +361,10 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
get
extensionPath
()
{
return
extensionDescription
.
extensionLocation
.
fsPath
;
},
storagePath
:
this
.
_storagePath
.
value
(
extensionDescription
),
asAbsolutePath
:
(
relativePath
:
string
)
=>
{
return
join
(
extensionDescription
.
extensionLocation
.
fsPath
,
relativePath
);
},
get
logger
()
{
checkProposedApiEnabled
(
extensionDescription
);
return
that
.
_extHostLogService
.
getExtLogger
(
extensionDescription
.
id
);
},
get
logDirectory
()
{
console
.
warn
(
`this PROPOSED API has been RENAMED to 'logPath'`
);
checkProposedApiEnabled
(
extensionDescription
);
...
...
src/vs/workbench/api/node/extHostLogService.ts
浏览文件 @
315cce83
...
...
@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
join
}
from
'
vs/base/common/paths
'
;
import
{
LogLevel
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
ILogService
,
DelegatedLogService
}
from
'
vs/platform/log/common/log
'
;
...
...
@@ -13,6 +14,8 @@ import { ExtHostLogServiceShape } from 'vs/workbench/api/node/extHost.protocol';
export
class
ExtHostLogService
extends
DelegatedLogService
implements
ILogService
,
ExtHostLogServiceShape
{
private
_loggers
:
Map
<
string
,
ExtHostLogger
>
=
new
Map
();
constructor
(
private
_windowId
:
number
,
logLevel
:
LogLevel
,
...
...
@@ -25,7 +28,54 @@ export class ExtHostLogService extends DelegatedLogService implements ILogServic
this
.
setLevel
(
level
);
}
getExtLogger
(
extensionID
:
string
):
ExtHostLogger
{
let
logger
=
this
.
_loggers
.
get
(
extensionID
);
if
(
!
logger
)
{
logger
=
this
.
createLogger
(
extensionID
);
this
.
_loggers
.
set
(
extensionID
,
logger
);
}
return
logger
;
}
getLogDirectory
(
extensionID
:
string
):
string
{
return
join
(
this
.
_logsPath
,
`
${
extensionID
}
_
${
this
.
_windowId
}
`
);
}
private
createLogger
(
extensionID
:
string
):
ExtHostLogger
{
const
logsDirPath
=
this
.
getLogDirectory
(
extensionID
);
const
logService
=
createSpdLogService
(
extensionID
,
this
.
getLevel
(),
logsDirPath
);
this
.
_register
(
this
.
onDidChangeLogLevel
(
level
=>
logService
.
setLevel
(
level
)));
return
new
ExtHostLogger
(
logService
);
}
}
export
class
ExtHostLogger
implements
vscode
.
Logger
{
constructor
(
private
readonly
_logService
:
ILogService
)
{
}
trace
(
message
:
string
,
...
args
:
any
[]):
void
{
return
this
.
_logService
.
trace
(
message
,
...
args
);
}
debug
(
message
:
string
,
...
args
:
any
[]):
void
{
return
this
.
_logService
.
debug
(
message
,
...
args
);
}
info
(
message
:
string
,
...
args
:
any
[]):
void
{
return
this
.
_logService
.
info
(
message
,
...
args
);
}
warn
(
message
:
string
,
...
args
:
any
[]):
void
{
return
this
.
_logService
.
warn
(
message
,
...
args
);
}
error
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
{
return
this
.
_logService
.
error
(
message
,
...
args
);
}
critical
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
{
return
this
.
_logService
.
critical
(
message
,
...
args
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录