Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b0cd8f84
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,发现更多精彩内容 >>
提交
b0cd8f84
编写于
1月 23, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#39574
上级
de24732a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
84 addition
and
41 deletion
+84
-41
src/vs/platform/log/common/log.ts
src/vs/platform/log/common/log.ts
+84
-41
未找到文件。
src/vs/platform/log/common/log.ts
浏览文件 @
b0cd8f84
...
...
@@ -7,8 +7,10 @@
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
createDecorator
as
createServiceDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
LogLevelChannelClient
}
from
'
vs/platform/log/common/logIpc
'
;
export
const
ILogService
=
createServiceDecorator
<
ILogService
>
(
'
logService
'
);
...
...
@@ -25,6 +27,7 @@ export enum LogLevel {
export
interface
ILogService
extends
IDisposable
{
_serviceBrand
:
any
;
onDidChangeLogLevel
:
Event
<
LogLevel
>
;
setLevel
(
level
:
LogLevel
):
void
;
getLevel
():
LogLevel
;
trace
(
message
:
string
,
...
args
:
any
[]):
void
;
...
...
@@ -35,27 +38,37 @@ export interface ILogService extends IDisposable {
critical
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
;
}
export
class
ConsoleLogMainService
implements
ILogServic
e
{
export
abstract
class
AbstractLogService
extends
Disposabl
e
{
_serviceBrand
:
any
;
private
level
:
LogLevel
=
LogLevel
.
Error
;
private
useColors
:
boolean
;
constructor
(
@
IEnvironmentService
environmentService
:
IEnvironmentService
)
{
this
.
setLevel
(
environmentService
.
logLevel
);
this
.
useColors
=
!
isWindows
;
}
private
readonly
_onDidChangeLogLevel
:
Emitter
<
LogLevel
>
=
this
.
_register
(
new
Emitter
<
LogLevel
>
());
readonly
onDidChangeLogLevel
:
Event
<
LogLevel
>
=
this
.
_onDidChangeLogLevel
.
event
;
setLevel
(
level
:
LogLevel
):
void
{
this
.
level
=
level
;
if
(
this
.
level
!==
level
)
{
this
.
level
=
level
;
this
.
_onDidChangeLogLevel
.
fire
(
this
.
level
);
}
}
getLevel
():
LogLevel
{
return
this
.
level
;
}
}
export
class
ConsoleLogMainService
extends
AbstractLogService
implements
ILogService
{
_serviceBrand
:
any
;
private
useColors
:
boolean
;
constructor
(
@
IEnvironmentService
environmentService
:
IEnvironmentService
)
{
super
();
this
.
setLevel
(
environmentService
.
logLevel
);
this
.
useColors
=
!
isWindows
;
}
trace
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Trace
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Trace
)
{
if
(
this
.
useColors
)
{
console
.
log
(
`\x1b[90m[main
${
new
Date
().
toLocaleTimeString
()}
]\x1b[0m`
,
message
,
...
args
);
}
else
{
...
...
@@ -65,7 +78,7 @@ export class ConsoleLogMainService implements ILogService {
}
debug
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Debug
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Debug
)
{
if
(
this
.
useColors
)
{
console
.
log
(
`\x1b[90m[main
${
new
Date
().
toLocaleTimeString
()}
]\x1b[0m`
,
message
,
...
args
);
}
else
{
...
...
@@ -75,7 +88,7 @@ export class ConsoleLogMainService implements ILogService {
}
info
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Info
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Info
)
{
if
(
this
.
useColors
)
{
console
.
log
(
`\x1b[90m[main
${
new
Date
().
toLocaleTimeString
()}
]\x1b[0m`
,
message
,
...
args
);
}
else
{
...
...
@@ -85,7 +98,7 @@ export class ConsoleLogMainService implements ILogService {
}
warn
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Warning
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Warning
)
{
if
(
this
.
useColors
)
{
console
.
warn
(
`\x1b[93m[main
${
new
Date
().
toLocaleTimeString
()}
]\x1b[0m`
,
message
,
...
args
);
}
else
{
...
...
@@ -95,7 +108,7 @@ export class ConsoleLogMainService implements ILogService {
}
error
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Error
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Error
)
{
if
(
this
.
useColors
)
{
console
.
error
(
`\x1b[91m[main
${
new
Date
().
toLocaleTimeString
()}
]\x1b[0m`
,
message
,
...
args
);
}
else
{
...
...
@@ -105,7 +118,7 @@ export class ConsoleLogMainService implements ILogService {
}
critical
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Critical
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Critical
)
{
if
(
this
.
useColors
)
{
console
.
error
(
`\x1b[90m[main
${
new
Date
().
toLocaleTimeString
()}
]\x1b[0m`
,
message
,
...
args
);
}
else
{
...
...
@@ -119,55 +132,47 @@ export class ConsoleLogMainService implements ILogService {
}
}
export
class
ConsoleLogService
implements
ILogService
{
export
class
ConsoleLogService
extends
AbstractLogService
implements
ILogService
{
_serviceBrand
:
any
;
private
level
:
LogLevel
=
LogLevel
.
Error
;
constructor
(
@
IEnvironmentService
environmentService
:
IEnvironmentService
)
{
super
();
this
.
setLevel
(
environmentService
.
logLevel
);
}
setLevel
(
level
:
LogLevel
):
void
{
this
.
level
=
level
;
}
getLevel
():
LogLevel
{
return
this
.
level
;
}
trace
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Trace
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Trace
)
{
console
.
log
(
'
%cTRACE
'
,
'
color: #888
'
,
message
,
...
args
);
}
}
debug
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Debug
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Debug
)
{
console
.
log
(
'
%cDEBUG
'
,
'
background: #eee; color: #888
'
,
message
,
...
args
);
}
}
info
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Info
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Info
)
{
console
.
log
(
'
%c INFO
'
,
'
color: #33f
'
,
message
,
...
args
);
}
}
warn
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Warning
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Warning
)
{
console
.
log
(
'
%c WARN
'
,
'
color: #993
'
,
message
,
...
args
);
}
}
error
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Error
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Error
)
{
console
.
log
(
'
%c ERR
'
,
'
color: #f33
'
,
message
,
...
args
);
}
}
critical
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
level
<=
LogLevel
.
Critical
)
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Critical
)
{
console
.
log
(
'
%cCRITI
'
,
'
background: #f33; color: white
'
,
message
,
...
args
);
}
}
...
...
@@ -175,22 +180,18 @@ export class ConsoleLogService implements ILogService {
dispose
():
void
{
}
}
export
class
MultiplexLogService
implements
ILogService
{
export
class
MultiplexLogService
extends
AbstractLogService
implements
ILogService
{
_serviceBrand
:
any
;
constructor
(
private
logServices
:
ILogService
[])
{
}
constructor
(
private
logServices
:
ILogService
[])
{
super
();
}
setLevel
(
level
:
LogLevel
):
void
{
for
(
const
logService
of
this
.
logServices
)
{
logService
.
setLevel
(
level
);
}
}
getLevel
():
LogLevel
{
for
(
const
logService
of
this
.
logServices
)
{
return
logService
.
getLevel
();
}
return
LogLevel
.
Info
;
super
.
setLevel
(
level
);
}
trace
(
message
:
string
,
...
args
:
any
[]):
void
{
...
...
@@ -236,8 +237,50 @@ export class MultiplexLogService implements ILogService {
}
}
export
class
FollowerLogService
extends
AbstractLogService
implements
ILogService
{
_serviceBrand
:
any
;
constructor
(
private
client
:
LogLevelChannelClient
,
private
logService
:
ILogService
)
{
super
();
this
.
_register
(
client
.
onDidChangeLogLevel
(
level
=>
logService
.
setLevel
(
level
)));
}
setLevel
(
level
:
LogLevel
):
void
{
this
.
client
.
setLogLevel
(
level
);
}
trace
(
message
:
string
,
...
args
:
any
[]):
void
{
this
.
logService
.
trace
(
message
,
...
args
);
}
debug
(
message
:
string
,
...
args
:
any
[]):
void
{
this
.
logService
.
debug
(
message
,
...
args
);
}
info
(
message
:
string
,
...
args
:
any
[]):
void
{
this
.
logService
.
info
(
message
,
...
args
);
}
warn
(
message
:
string
,
...
args
:
any
[]):
void
{
this
.
logService
.
warn
(
message
,
...
args
);
}
error
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
{
this
.
logService
.
error
(
message
,
...
args
);
}
critical
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
{
this
.
logService
.
critical
(
message
,
...
args
);
}
dispose
():
void
{
this
.
logService
.
dispose
();
}
}
export
class
NullLogService
implements
ILogService
{
_serviceBrand
:
any
;
readonly
onDidChangeLogLevel
:
Event
<
LogLevel
>
=
new
Emitter
<
LogLevel
>
().
event
;
setLevel
(
level
:
LogLevel
):
void
{
}
getLevel
():
LogLevel
{
return
LogLevel
.
Info
;
}
trace
(
message
:
string
,
...
args
:
any
[]):
void
{
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录