Skip to content

Commit 5044acf

Browse files
committed
[event-viewer] adds debug loging when command execution throws error
1 parent 812a6c2 commit 5044acf

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
### Changed
1313
- **[AppLogger]:**: introduce debug instance
14+
- **[event-viewer]:**: adds debug loging when command execution throws error
1415

1516
### Fixed
1617
- **[log-selection]:** event-logs command parsing when thousands separator is '.' instead of ','

src/app/services/powershell/powershell-command-executor.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Shell from 'node-powershell';
22
import { GlobalUtils } from '../global-utils';
3+
import { AppLogger } from '../AppLogger';
34

45

56

@@ -35,7 +36,13 @@ export class PsCommandExecutor {
3536
.then(() => _ps.addCommand(command))
3637
.then(() => _ps.invoke())
3738
.catch(e => {
38-
if (!ignoreError) console.error(e);
39+
if (!ignoreError) {
40+
console.error('The following command threw an error.\n' + command);
41+
console.error(e);
42+
AppLogger.getDebug().logErrorMessage('The following command threw an error.\n' + command);
43+
AppLogger.getDebug().logError(e);
44+
}
45+
3946
return '';
4047
})
4148
.finally(() => {

src/app/services/powershell/powershell-commands.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export class PowershellCommands {
5050
if (computerName) command += ` -ComputerName "${computerName}"`;
5151
command += ' -List';
5252

53-
AppLogger.getDebug().logDebug(command);
5453
return PsCommandExecutor.executeCommand(command, false, 90)
5554
.then(output => PowershellCommands._parseEventViewersList(output))
5655
.then(events => {
@@ -96,7 +95,7 @@ export class PowershellCommands {
9695
//add select part
9796
command += PowershellCommands._selectEventCommand;
9897
//execute and parse
99-
return PsCommandExecutor.executeCommand(command, true)
98+
return PsCommandExecutor.executeCommand(command, lastEvent == null)
10099
.then(output => PowershellCommands._parseEventsCommandOutput(output));
101100
}
102101

0 commit comments

Comments
 (0)