Commit 7ce78108 authored by Tobias Steiner's avatar Tobias Steiner
Browse files

Add a shortcut to retrieve a named reporter

parent d755c066
......@@ -6,6 +6,7 @@ import {LoggerInstance} from 'winston';
import UriBuilder from './uri-builder';
import {InterfaceReporter, InterfaceReporterCollection, Reporter} from './reporter';
import fs = require('fs');
import {InterfaceCore} from '../dist/core';
export interface InterfaceCore {
name: string;
......@@ -102,11 +103,18 @@ class Core {
/**
* Get a singleton reporter instance with a specific name
* @param {number} interval
* @param {number | string} nameOrInterval The interval or a shortcut for the name
* @param {string} name
* @returns {Reporter}
*/
public getReporter(interval: number = 10000, name: string = 'default'): InterfaceReporter {
public getReporter(nameOrInterval: number | string = 10000, name: string = 'default'): InterfaceReporter {
let interval = 10000;
if (typeof nameOrInterval === 'number') {
interval = nameOrInterval;
} else {
name = nameOrInterval;
}
let reporter = this.reporter.find((r) => r.name === name);
if (typeof reporter === 'undefined') {
reporter = {name, reporter: new Reporter(this, interval)};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment