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

Commitc5a6e38

Browse files
committed
setup logger and environment
1 parentd460870 commitc5a6e38

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

‎src/channel/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import setupActions from '../actions/setupActions'
66
importsolutionActionsfrom'../actions/solutionActions'
77
importtutorialConfigfrom'../actions/tutorialConfig'
88
import{COMMANDS}from'../editor/commands'
9+
importloggerfrom'../services/logger'
910
importContextfrom'./context'
1011

1112
interfaceChannel{
@@ -120,7 +121,7 @@ class Channel implements Channel {
120121
return
121122

122123
default:
123-
console.log(`No match for action type:${actionType}`)
124+
logger(`No match for action type:${actionType}`)
124125
return
125126
}
126127
}

‎src/environment.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
interfaceEnvironment{
2+
LOG:boolean
3+
}
4+
5+
constenvironment:Environment={
6+
LOG:(process.env.LOG||'').toLowerCase()==='test',
7+
}
8+
9+
exportdefaultenvironment

‎src/services/git/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
importnodefrom'../node'
2+
importloggerfrom'../logger'
23

34
constgitOrigin='coderoad'
45

@@ -48,7 +49,7 @@ export async function saveCommit(message: string): Promise<void> {
4849
console.error(stderr)
4950
thrownewError('Error saving progress to Git')
5051
}
51-
console.log('save with commit & continue stdout',stdout)
52+
logger(['save with commit & continue stdout',stdout])
5253
}
5354

5455
exportasyncfunctionclear():Promise<void>{

‎src/services/logger/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
importenviromentfrom'../../environment'
2+
3+
constlogger=(message:string|string[])=>{
4+
if(!enviroment.LOG){
5+
return
6+
}
7+
if(Array.isArray(message)){
8+
message.forEach(console.log)
9+
}else{
10+
console.log(message)
11+
}
12+
}
13+
14+
exportdefaultlogger

‎src/services/testRunner/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import{getOutputChannel}from'../../editor/outputChannel'
22
importnodefrom'../../services/node'
3+
importloggerfrom'../../services/logger'
34
importparserfrom'./parser'
45
import{debounce,throttle}from'./throttle'
56

@@ -27,7 +28,8 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
2728
if(!startTime){
2829
return
2930
}
30-
console.log('------------------- RUN TEST -------------------')
31+
32+
logger('------------------- RUN TEST -------------------')
3133

3234
// flag as running
3335
callbacks.onRun(payload)
@@ -44,7 +46,8 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
4446
if(!debounce(startTime)){
4547
return
4648
}
47-
console.log('----------------- PROCESS TEST -----------------')
49+
50+
logger('----------------- PROCESS TEST -----------------')
4851

4952
const{ stdout, stderr}=result
5053

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp