Skip to content

Commit a867128

Browse files
committed
Added: Logger
1 parent 833df14 commit a867128

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

src/logging/logger.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1+
import { LoggerOptions } from './logger_options.ts';
2+
import { StdOutFunctionType } from './std_out_function_type.ts';
3+
14
export default class Logger {
2-
constructor() {
3-
5+
private _stdout : StdOutFunctionType;
6+
private _options? : LoggerOptions;
7+
constructor(
8+
stdout : StdOutFunctionType,
9+
options? : LoggerOptions
10+
) {
11+
this._stdout = stdout;
12+
this._options = options;
13+
}
14+
15+
/**
16+
* This getter returns the passed in standard output function.
17+
*/
18+
get stdout() : StdOutFunctionType {
19+
return this._stdout;
20+
}
21+
22+
/**
23+
* This getter returns the passed in options for the logger.
24+
*/
25+
get options() : LoggerOptions | undefined {
26+
return this._options;
427
}
528
}

src/logging/logger_options.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* This interface describes all options available for the logger.
3+
*/
4+
export interface LoggerOptions {
5+
/** Enables colors */
6+
color? : boolean,
7+
/** Adds a timestamp to the log message */
8+
addTimestamp? : boolean
9+
}

src/logging/mod.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { StdOutFunctionType } from './std_out_function_type.ts';
2+
3+
export type {
4+
StdOutFunctionType
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* This type describes the default function interface for the logger standard output.
3+
* @param data The data to log
4+
*/
5+
export type StdOutFunctionType = (data : string) => void;

0 commit comments

Comments
 (0)