karma-runner / karma-runner/karma

logger.js ignores layout.pattern

Open
#2,414 1 comment 0 reactions 0 assignees View on GitHub
help wanted needs: investigation
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### Expected behaviour

In [`karma/lib/logger.js`](https://github.com/karma-runner/karma/blob/master/lib/logger.js#L23), `setup` should use the `layout.pattern` string if it exists.
### Actual behaviour

When `layout.type === 'pattern'`, `setup` only uses one of the built-in constants:

``` js
var pattern = colors ? constant.COLOR_PATTERN : constant.NO_COLOR_PATTERN
```
### Environment Details
- Karma version (output of `karma --version`): 1.3.0
- Relevant part of your `karma.config.js` file

``` js
loggers: [
{
type: 'console',
layout: {
type: 'pattern',
pattern: '%[%d{ISO8601}:%p [%c]: %]%m'
}
}
]
```
### Steps to reproduce the behaviour
1. Supply a custom logger in `karma.config.js` as specified above.
### Comment

If this is indeed broken, I can submit a PR.

Further, I realize that fixing this to use the provided `pattern` will then ignore the `colors` boolean. This might be addressed by having `layout.colorPattern` and `layout.noColorPattern` which get assigned appropriately to `layout.pattern`. I can submit a PR for this as well.

Thanks.

Contributor guide

Open the contributing guide

Research direction

Start in karma/lib/logger.js at setup and compare the pattern layout handling with the supplied karma.config.js example. Reproduce the issue with a custom console logger and verify that the configured layout.pattern is used, including the interaction with the colors setting.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.