Skip to content

Fix/continue #255

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
clean up logs
Signed-off-by: shmck <[email protected]>
  • Loading branch information
ShMcK committed Apr 18, 2020
commit aa863043860fdc605f5d47eb4c94595f41a39bd3
4 changes: 2 additions & 2 deletions src/channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class Channel implements Channel {
case 'TEST_PASS':
const tutorial = this.context.tutorial.get()
if (!tutorial) {
throw new Error('Error with current tutorial')
throw new Error('ERROR: Tutorial not found in test run')
}
// update local storage stepProgress
const progress = this.context.progress.setStepComplete(tutorial, action.payload.stepId)
Expand All @@ -340,7 +340,7 @@ class Channel implements Channel {
// send message
const sentToClient = await this.postMessage(action)
if (!sentToClient) {
throw new Error(`Message post failure: ${JSON.stringify(action)}`)
throw new Error(`ERROR: Message post failure: ${JSON.stringify(action)}`)
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions src/services/logger/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { LOG } from '../../environment'

const logger = (message: string | string[]) => {
export type Log = string | object

const logger = (...messages: Log[]): void => {
if (!LOG) {
return
}
if (Array.isArray(message)) {
message.forEach(console.log)
} else {
console.log(message)
// Inside vscode, you console.log does not allow more than 1 param
// to get around it, we can log with multiple log statements
for (const message of messages) {
if (typeof message === 'object') {
console.log(JSON.stringify(message))
} else {
console.log(message)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions web-app/src/components/ErrorBoundary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class ErrorBoundary extends React.Component {
// Display fallback UI
this.setState({ errorMessage: error.message })
// You can also log the error to an error reporting service
logger('ERROR in component:', JSON.stringify(error))
logger('ERROR info:', JSON.stringify(info))
logger('ERROR in component:', error)
logger('ERROR info:', info)
}

public render() {
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/components/Router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ const useRouter = (): Output => {
} else if (Array.isArray(path)) {
pathMatch = path.some((p) => state.matches(p))
} else {
throw new Error(`Invalid route path ${JSON.stringify(path)}`)
throw new Error(`ERROR: Invalid route path: ${JSON.stringify(path)}`)
}
if (pathMatch) {
// @ts-ignore
return child.props.children
}
}
const message = `No Route matches for ${JSON.stringify(state)}`
const message = `ERROR: No Route matches for ${JSON.stringify(state)}`
onError(new Error(message))
console.warn(message)
return null
Expand Down
10 changes: 8 additions & 2 deletions web-app/src/services/logger/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { LOG } from '../../environment'

const logger = (...messages: string[]) => {
export type Log = string | object

const logger = (...messages: Log[]): void => {
if (!LOG) {
return
}
// Inside vscode, you console.log does not allow more than 1 param
// to get around it, we can log with multiple log statements
for (const message of messages) {
console.log(message)
if (typeof message === 'object') {
console.log(JSON.stringify(message))
} else {
console.log(message)
}
}
}

Expand Down