[Gradle, JS] Add custom log4js appender for karma
#KT-38109 fixed
This commit is contained in:
+3
@@ -79,6 +79,9 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) :
|
||||
config.plugins = config.plugins || [];
|
||||
config.plugins.push('karma-*'); // default
|
||||
config.plugins.push('kotlin-test-js-runner/karma-kotlin-reporter.js');
|
||||
|
||||
config.loggers = config.loggers || [];
|
||||
config.loggers.push({type: 'kotlin-test-js-runner/tc-log-appender.js'});
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
import typescript from 'rollup-plugin-typescript2';
|
||||
import nodeResolve from 'rollup-plugin-node-resolve';
|
||||
import commonjs from 'rollup-plugin-commonjs';
|
||||
@@ -47,6 +52,13 @@ export default [
|
||||
format: 'cjs'
|
||||
}
|
||||
},
|
||||
{
|
||||
input: './tc-log-appender.js',
|
||||
output: {
|
||||
file: 'lib/tc-log-appender.js',
|
||||
format: 'cjs'
|
||||
}
|
||||
},
|
||||
{
|
||||
input: './mocha-kotlin-reporter.js',
|
||||
external: ['path', 'util'],
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import {tcEscape} from "./src/teamcity-format"
|
||||
|
||||
const consoleLog = console.log.bind(console);
|
||||
|
||||
function consoleAppender(layout, timezoneOffset) {
|
||||
return (loggingEvent) => {
|
||||
consoleLog(tcEscape(layout(loggingEvent, timezoneOffset)));
|
||||
};
|
||||
}
|
||||
|
||||
function configure(config, layouts) {
|
||||
let layout = layouts.colouredLayout;
|
||||
if (config.layout) {
|
||||
layout = layouts.layout(config.layout.type, config.layout);
|
||||
}
|
||||
return consoleAppender(layout, config.timezoneOffset);
|
||||
}
|
||||
|
||||
module.exports.configure = configure;
|
||||
Reference in New Issue
Block a user