Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
dc4c7631
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,发现更多精彩内容 >>
提交
dc4c7631
编写于
9月 06, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use backup channels when spdlog fails and log telemetry
上级
03a8c0c0
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
171 addition
and
21 deletion
+171
-21
src/vs/platform/output/node/outputAppender.ts
src/vs/platform/output/node/outputAppender.ts
+3
-17
src/vs/workbench/api/node/extHostOutputService.ts
src/vs/workbench/api/node/extHostOutputService.ts
+11
-1
src/vs/workbench/parts/output/electron-browser/outputServices.ts
...workbench/parts/output/electron-browser/outputServices.ts
+157
-3
未找到文件。
src/vs/platform/output/node/outputAppender.ts
浏览文件 @
dc4c7631
...
...
@@ -5,27 +5,13 @@
import
{
createRotatingLogger
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
RotatingLogger
}
from
'
spdlog
'
;
interface
Appender
{
critical
(
content
:
string
);
flush
();
}
export
class
OutputAppender
{
private
appender
:
Append
er
;
private
appender
:
RotatingLogg
er
;
constructor
(
name
:
string
,
file
:
string
)
{
// Do not crash if logger cannot be loaded
try
{
this
.
appender
=
createRotatingLogger
(
name
,
file
,
1024
*
1024
*
30
,
1
);
(
<
RotatingLogger
>
this
.
appender
).
clearFormatters
();
}
catch
(
error
)
{
console
.
error
(
error
);
this
.
appender
=
{
critical
()
{
},
flush
()
{
},
};
}
this
.
appender
.
clearFormatters
();
}
append
(
content
:
string
):
void
{
...
...
src/vs/workbench/api/node/extHostOutputService.ts
浏览文件 @
dc4c7631
...
...
@@ -111,7 +111,17 @@ export class ExtHostOutputService {
if
(
!
name
)
{
throw
new
Error
(
'
illegal argument `name`. must not be falsy
'
);
}
else
{
return
push
?
new
ExtHostPushOutputChannel
(
name
,
this
.
_proxy
)
:
new
ExtHostFileOutputChannel
(
name
,
this
.
_outputDir
,
this
.
_proxy
);
if
(
push
)
{
return
new
ExtHostPushOutputChannel
(
name
,
this
.
_proxy
);
}
else
{
// Do not crash if logger cannot be created
try
{
return
new
ExtHostFileOutputChannel
(
name
,
this
.
_outputDir
,
this
.
_proxy
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
new
ExtHostPushOutputChannel
(
name
,
this
.
_proxy
);
}
}
}
}
}
src/vs/workbench/parts/output/electron-browser/outputServices.ts
浏览文件 @
dc4c7631
...
...
@@ -5,6 +5,7 @@
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
extfs
from
'
vs/base/node/extfs
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
...
...
@@ -15,7 +16,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
IOutputChannelDescriptor
,
IOutputChannel
,
IOutputService
,
Extensions
,
OUTPUT_PANEL_ID
,
IOutputChannelRegistry
,
OUTPUT_SCHEME
,
OUTPUT_MIME
,
LOG_SCHEME
,
LOG_MIME
,
CONTEXT_ACTIVE_LOG_OUTPUT
}
from
'
vs/workbench/parts/output/common/output
'
;
import
{
IOutputChannelDescriptor
,
IOutputChannel
,
IOutputService
,
Extensions
,
OUTPUT_PANEL_ID
,
IOutputChannelRegistry
,
OUTPUT_SCHEME
,
OUTPUT_MIME
,
LOG_SCHEME
,
LOG_MIME
,
CONTEXT_ACTIVE_LOG_OUTPUT
,
MAX_OUTPUT_LENGTH
}
from
'
vs/workbench/parts/output/common/output
'
;
import
{
OutputPanel
}
from
'
vs/workbench/parts/output/browser/outputPanel
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
...
...
@@ -34,10 +35,12 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import
{
toLocalISOString
}
from
'
vs/base/common/date
'
;
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
binarySearch
}
from
'
vs/base/common/arrays
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
OutputAppender
}
from
'
vs/platform/output/node/outputAppender
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
const
OUTPUT_ACTIVE_CHANNEL_KEY
=
'
output.activechannel
'
;
...
...
@@ -408,6 +411,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
IWindowService
windowService
:
IWindowService
,
@
ILogService
private
logService
:
ILogService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
IContextKeyService
private
contextKeyService
:
IContextKeyService
,
)
{
...
...
@@ -551,7 +555,17 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
if
(
channelData
&&
channelData
.
file
)
{
return
this
.
instantiationService
.
createInstance
(
FileOutputChannel
,
channelData
,
uri
);
}
try
{
return
this
.
instantiationService
.
createInstance
(
OutputChannelBackedByFile
,
{
id
,
label
:
channelData
?
channelData
.
label
:
''
},
this
.
outputDir
,
uri
);
}
catch
(
e
)
{
// Do not crash if spdlog rotating logger cannot be loaded (workaround for https://github.com/Microsoft/vscode/issues/47883)
this
.
logService
.
error
(
e
);
/* __GDPR__
"output.channel.creation.error" : {}
*/
this
.
telemetryService
.
publicLog
(
'
output.channel.creation.error
'
);
return
this
.
instantiationService
.
createInstance
(
BufferredOutputChannel
,
{
id
,
label
:
channelData
?
channelData
.
label
:
''
});
}
}
private
doShowChannel
(
channel
:
IOutputChannel
,
preserveFocus
:
boolean
):
Thenable
<
void
>
{
...
...
@@ -626,3 +640,143 @@ export class LogContentProvider {
return
channel
;
}
}
// Remove this channel when https://github.com/Microsoft/vscode/issues/47883 is fixed
class
BufferredOutputChannel
extends
Disposable
implements
OutputChannel
{
readonly
id
:
string
;
readonly
label
:
string
;
readonly
file
:
URI
=
null
;
scrollLock
:
boolean
=
false
;
protected
_onDidAppendedContent
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
readonly
onDidAppendedContent
:
Event
<
void
>
=
this
.
_onDidAppendedContent
.
event
;
private
readonly
_onDispose
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
readonly
onDispose
:
Event
<
void
>
=
this
.
_onDispose
.
event
;
private
modelUpdater
:
RunOnceScheduler
;
private
model
:
ITextModel
;
private
readonly
bufferredContent
:
BufferedContent
;
private
lastReadId
:
number
=
void
0
;
constructor
(
protected
readonly
outputChannelIdentifier
:
IOutputChannelDescriptor
,
@
IModelService
private
modelService
:
IModelService
,
@
IModeService
private
modeService
:
IModeService
)
{
super
();
this
.
id
=
outputChannelIdentifier
.
id
;
this
.
label
=
outputChannelIdentifier
.
label
;
this
.
modelUpdater
=
new
RunOnceScheduler
(()
=>
this
.
updateModel
(),
300
);
this
.
_register
(
toDisposable
(()
=>
this
.
modelUpdater
.
cancel
()));
this
.
bufferredContent
=
new
BufferedContent
();
this
.
_register
(
toDisposable
(()
=>
this
.
bufferredContent
.
clear
()));
}
append
(
output
:
string
)
{
this
.
bufferredContent
.
append
(
output
);
if
(
!
this
.
modelUpdater
.
isScheduled
())
{
this
.
modelUpdater
.
schedule
();
}
}
clear
():
void
{
if
(
this
.
modelUpdater
.
isScheduled
())
{
this
.
modelUpdater
.
cancel
();
}
if
(
this
.
model
)
{
this
.
model
.
setValue
(
''
);
}
this
.
bufferredContent
.
clear
();
this
.
lastReadId
=
void
0
;
}
loadModel
():
TPromise
<
ITextModel
>
{
const
{
value
,
id
}
=
this
.
bufferredContent
.
getDelta
(
this
.
lastReadId
);
if
(
this
.
model
)
{
this
.
model
.
setValue
(
value
);
}
else
{
this
.
model
=
this
.
createModel
(
value
);
}
this
.
lastReadId
=
id
;
return
TPromise
.
as
(
this
.
model
);
}
private
createModel
(
content
:
string
):
ITextModel
{
const
model
=
this
.
modelService
.
createModel
(
content
,
this
.
modeService
.
getOrCreateMode
(
OUTPUT_MIME
),
URI
.
from
({
scheme
:
OUTPUT_SCHEME
,
path
:
this
.
id
}));
const
disposables
:
IDisposable
[]
=
[];
disposables
.
push
(
model
.
onWillDispose
(()
=>
{
this
.
model
=
null
;
dispose
(
disposables
);
}));
return
model
;
}
private
updateModel
():
void
{
if
(
this
.
model
)
{
const
{
value
,
id
}
=
this
.
bufferredContent
.
getDelta
(
this
.
lastReadId
);
this
.
lastReadId
=
id
;
const
lastLine
=
this
.
model
.
getLineCount
();
const
lastLineMaxColumn
=
this
.
model
.
getLineMaxColumn
(
lastLine
);
this
.
model
.
applyEdits
([
EditOperation
.
insert
(
new
Position
(
lastLine
,
lastLineMaxColumn
),
value
)]);
this
.
_onDidAppendedContent
.
fire
();
}
}
dispose
():
void
{
this
.
_onDispose
.
fire
();
super
.
dispose
();
}
}
class
BufferedContent
{
private
data
:
string
[]
=
[];
private
dataIds
:
number
[]
=
[];
private
idPool
=
0
;
private
length
=
0
;
public
append
(
content
:
string
):
void
{
this
.
data
.
push
(
content
);
this
.
dataIds
.
push
(
++
this
.
idPool
);
this
.
length
+=
content
.
length
;
this
.
trim
();
}
public
clear
():
void
{
this
.
data
.
length
=
0
;
this
.
dataIds
.
length
=
0
;
this
.
length
=
0
;
}
private
trim
():
void
{
if
(
this
.
length
<
MAX_OUTPUT_LENGTH
*
1.2
)
{
return
;
}
while
(
this
.
length
>
MAX_OUTPUT_LENGTH
)
{
this
.
dataIds
.
shift
();
const
removed
=
this
.
data
.
shift
();
this
.
length
-=
removed
.
length
;
}
}
public
getDelta
(
previousId
?:
number
):
{
value
:
string
,
id
:
number
}
{
let
idx
=
-
1
;
if
(
previousId
!==
void
0
)
{
idx
=
binarySearch
(
this
.
dataIds
,
previousId
,
(
a
,
b
)
=>
a
-
b
);
}
const
id
=
this
.
idPool
;
if
(
idx
>=
0
)
{
const
value
=
strings
.
removeAnsiEscapeCodes
(
this
.
data
.
slice
(
idx
+
1
).
join
(
''
));
return
{
value
,
id
};
}
else
{
const
value
=
strings
.
removeAnsiEscapeCodes
(
this
.
data
.
join
(
''
));
return
{
value
,
id
};
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录