File tree 2 files changed +15
-15
lines changed
2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,19 @@ export enum LogLevel {
16
16
Error ,
17
17
}
18
18
19
- export class Logger {
19
+ /** Interface for logging operations. New features should use this interface for the "type" of logger.
20
+ * This will allow for easy mocking of the logger during unit tests.
21
+ */
22
+ export interface ILogger {
23
+ write ( message : string , ...additionalMessages : string [ ] ) ;
24
+ writeDiagnostic ( message : string , ...additionalMessages : string [ ] ) ;
25
+ writeVerbose ( message : string , ...additionalMessages : string [ ] ) ;
26
+ writeWarning ( message : string , ...additionalMessages : string [ ] ) ;
27
+ writeAndShowWarning ( message : string , ...additionalMessages : string [ ] ) ;
28
+ writeError ( message : string , ...additionalMessages : string [ ] ) ;
29
+ }
30
+
31
+ export class Logger implements ILogger {
20
32
21
33
public logBasePath : string ;
22
34
public logSessionPath : string ;
Original file line number Diff line number Diff line change 2
2
* Copyright (C) Microsoft Corporation. All rights reserved.
3
3
*--------------------------------------------------------*/
4
4
5
- import { Logger , LogLevel } from "../src/logging" ;
6
-
7
- export class MockLogger extends Logger {
8
- // Note - This is not a true mock as the constructor is inherited and causes errors due to trying load
9
- // the "PowerShell Extension Logs" multiple times. Ideally logging should be via an interface and then
10
- // we can mock correctly.
11
-
12
- public dispose ( ) { return undefined ; }
13
-
14
- public getLogFilePath ( baseName : string ) : string { return "mock" ; }
15
-
16
- public writeAtLevel ( logLevel : LogLevel , message : string , ...additionalMessages : string [ ] ) { return undefined ; }
5
+ import { ILogger } from "../src/logging" ;
17
6
7
+ export class MockLogger implements ILogger {
18
8
public write ( message : string , ...additionalMessages : string [ ] ) { return undefined ; }
19
9
20
10
public writeDiagnostic ( message : string , ...additionalMessages : string [ ] ) { return undefined ; }
@@ -28,6 +18,4 @@ export class MockLogger extends Logger {
28
18
public writeError ( message : string , ...additionalMessages : string [ ] ) { return undefined ; }
29
19
30
20
public writeAndShowError ( message : string , ...additionalMessages : string [ ] ) { return undefined ; }
31
-
32
- public startNewLog ( minimumLogLevel : string = "Normal" ) { return undefined ; }
33
21
}
You can’t perform that action at this time.
0 commit comments