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

Feature/logger#74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 2 commits intomasterfromfeature/logger
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletionsrc/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@ import setupActions from '../actions/setupActions'
import solutionActions from '../actions/solutionActions'
import tutorialConfig from '../actions/tutorialConfig'
import { COMMANDS } from '../editor/commands'
import logger from '../services/logger'
import Context from './context'

interface Channel {
Expand DownExpand Up@@ -120,7 +121,7 @@ class Channel implements Channel {
return

default:
console.log(`No match for action type: ${actionType}`)
logger(`No match for action type: ${actionType}`)
return
}
}
Expand Down
13 changes: 13 additions & 0 deletionssrc/environment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
require('dotenv').config({
path: './.env',
})

interface Environment {
LOG: boolean
}

const environment: Environment = {
LOG: (process.env.LOG || '').toLowerCase() === 'test',
}

export default environment
3 changes: 2 additions & 1 deletionsrc/services/git/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
import node from '../node'
import logger from '../logger'

const gitOrigin = 'coderoad'

Expand DownExpand Up@@ -48,7 +49,7 @@ export async function saveCommit(message: string): Promise<void> {
console.error(stderr)
throw new Error('Error saving progress to Git')
}
console.log('save with commit & continue stdout', stdout)
logger(['save with commit & continue stdout', stdout])
}

export async function clear(): Promise<void> {
Expand Down
14 changes: 14 additions & 0 deletionssrc/services/logger/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
import enviroment from '../../environment'

const logger = (message: string | string[]) => {
if (!enviroment.LOG) {
return
}
if (Array.isArray(message)) {
message.forEach(console.log)
} else {
console.log(message)
}
}

export default logger
7 changes: 5 additions & 2 deletionssrc/services/testRunner/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
import { getOutputChannel } from '../../editor/outputChannel'
import node from '../../services/node'
import logger from '../../services/logger'
import parser from './parser'
import { debounce, throttle } from './throttle'

Expand DownExpand Up@@ -27,7 +28,8 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
if (!startTime) {
return
}
console.log('------------------- RUN TEST -------------------')

logger('------------------- RUN TEST -------------------')

// flag as running
callbacks.onRun(payload)
Expand All@@ -44,7 +46,8 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
if (!debounce(startTime)) {
return
}
console.log('----------------- PROCESS TEST -----------------')

logger('----------------- PROCESS TEST -----------------')

const { stdout, stderr } = result

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp