Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4e1e1a5

Browse files
committed
send src logs to output channel
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent389181f commit4e1e1a5

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

‎src/actions/onOpenLogs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import*asTfrom'typings'
2-
import{showOutput}from'../services/testRunner/output'
2+
import{showOutput}from'../services/logger/output'
33

44
exportconstonOpenLogs=async(action:T.Action):Promise<void>=>{
55
constchannel=action.payload.channel

‎src/environment.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ export type Env = 'test' | 'local' | 'development' | 'production'
1010
//@ts-ignore
1111
exportconstNODE_ENV:Env=process.env.NODE_ENV||'development'
1212

13-
// toggle logging
14-
exportconstLOG=(process.env.CODEROAD_ENABLE_LOG||'').toLowerCase()==='true'
15-
1613
// error logging tool
1714
exportconstINSTRUMENTATION_KEY='6ff37c76-72f3-48e3-a1b9-d5636f519b7b'
1815

‎src/services/logger/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import{LOG}from'../../environment'
1+
import{getOutputChannel}from'./output'
22

33
exporttypeLog=any
44

5+
constlogChannel=getOutputChannel('CodeRoad (Logs)')
6+
57
constlogger=(...messages:Log[]):void=>{
6-
if(!LOG){
7-
return
8-
}
98
// Inside vscode, you console.log does not allow more than 1 param
109
// to get around it, we can log with multiple log statements
1110
for(constmessageofmessages){
1211
if(typeofmessage==='object'){
13-
console.log(JSON.stringify(message))
12+
logChannel.appendLine(JSON.stringify(message))
1413
}else{
15-
console.log(message)
14+
logChannel.appendLine(message)
1615
}
1716
}
1817
}

‎src/services/testRunner/output.tsrenamed to‎src/services/logger/output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const channels:
66
/* */
77
}={}
88

9-
constgetOutputChannel=(name:string):vscode.OutputChannel=>{
9+
exportconstgetOutputChannel=(name:string):vscode.OutputChannel=>{
1010
if(!channels[name]){
1111
channels[name]=vscode.window.createOutputChannel(name)
1212
}

‎src/services/testRunner/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import parser, { ParserOutput } from './parser'
66
importparseSubtasksfrom'./subtasks'
77
import{debounce,throttle}from'./throttle'
88
import{onError}from'../telemetry'
9-
import{clearOutput,addOutput}from'./output'
9+
import{clearOutput,addOutput}from'../logger/output'
1010
import{formatFailOutput}from'./formatOutput'
1111

1212
interfaceCallbacks{
@@ -18,7 +18,6 @@ interface Callbacks {
1818
}
1919

2020
constfailChannelName='CodeRoad (Tests)'
21-
constlogChannelName='CodeRoad (Logs)'
2221

2322
interfaceTestRunnerParams{
2423
position:T.Position
@@ -91,7 +90,7 @@ const createTestRunner = (data: TT.Tutorial, callbacks: Callbacks): ((params: an
9190

9291
consttap:ParserOutput=parser(stdout||'')
9392

94-
addOutput({channel:logChannelName,text:tap.logs.join('\n'),show:false})
93+
logger(tap.logs.join('\n'))
9594

9695
if(stderr){
9796
if(!tap.failed.length){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp