Skip to content

Commit

Permalink
fix: Remove terminal colors, closes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
zenflow committed Mar 15, 2021
1 parent 32b1460 commit 90e98bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"test": "yarn lint && yarn build && yarn test-only"
},
"dependencies": {
"chalk": "^4.1.0",
"cloneable-readable": "^2.0.1",
"merge-stream": "^2.0.0",
"npm-run-path": "^4.0.1",
Expand Down
11 changes: 4 additions & 7 deletions src/core/CompositeService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { formatWithOptions } from 'util'
import { Service } from './Service'
import mergeStream from 'merge-stream'
import chalk from 'chalk'
import { Service } from './Service'
import {
NormalizedCompositeServiceConfig,
validateAndNormalizeConfig,
Expand Down Expand Up @@ -55,11 +54,9 @@ export class CompositeService {
)

outputStream.add(
this.services.map(({ output, id }, i) => {
// luminosity of 20 because at 256 colors, luminosity from 16 to 24 yields the most colors (12 colors) while keeping high contrast with text
const label = chalk.bgHsl((i / this.services.length) * 360, 100, 20)(id)
return output.pipe(mapStreamLines(line => `${label} | ${line}`))
}),
this.services.map(({ output, id }) =>
output.pipe(mapStreamLines(line => `${id} | ${line}`)),
),
)

this.logger.log('debug', 'Starting composite service...')
Expand Down
5 changes: 1 addition & 4 deletions src/core/Logger.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { PassThrough } from 'stream'
import chalk from 'chalk'

export type LogLevel = 'debug' | 'info' | 'error'

const orderedLogLevels: LogLevel[] = ['error', 'info', 'debug']
const logLevelColors = { error: 'red', info: 'teal', debug: 'yellow' }

export class Logger {
private level: LogLevel
Expand All @@ -14,9 +12,8 @@ export class Logger {
}
public log(level: LogLevel, text: string) {
if (this.shouldLog(level)) {
const label = chalk.keyword(logLevelColors[level])(`(${level})`)
for (const line of text.split('\n')) {
this.output.write(` ${label} ${line}\n`)
this.output.write(` (${level}) ${line}\n`)
}
}
}
Expand Down

0 comments on commit 90e98bb

Please sign in to comment.