Skip to content

Commit ec6767d

Browse files
More logging enhancements
1 parent 0628e52 commit ec6767d

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@types/js-yaml": "^4.0.5",
2121
"@types/ldap-escape": "^2.0.0",
2222
"@types/ldapjs": "^2.2.5",
23+
"@types/node": "^20.4.8",
2324
"@types/swagger-ui-express": "^4.1.3",
2425
"nodemon": "^2.0.21",
2526
"shx": "^0.3.4",

src/logging.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const appInsights = require("applicationinsights");
22

3-
import { SeverityLevel, TelemetryType } from "applicationinsights/out/Declarations/Contracts";
3+
import { SeverityLevel } from "applicationinsights/out/Declarations/Contracts";
44
import TelemetryClient from "applicationinsights/out/Library/TelemetryClient";
55

66
interface ILogger {
@@ -51,8 +51,8 @@ export function LogError(ex: string) {
5151
export function SetupLogging() {
5252
if(process.env.APPLICATIONINSIGHTS_CONNECTION_STRING) {
5353
console.log("Using AppInsights Logger")
54-
appInsights.setup(process.env.APPLICATIONINSIGHTS_CONNECTION_STRING).start();
55-
54+
appInsights.setup(process.env.APPLICATIONINSIGHTS_CONNECTION_STRING).start();
55+
5656
const telemetryClient = appInsights.defaultClient;
5757

5858
logger = new AiLogger(telemetryClient);

src/services/ldapClient.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ async function SearchAllAsyncNoExceptionHandling(groupName: string): SearchAllRe
9797
});
9898

9999
response.on('end', (result: any) => {
100-
if (result.status !== 0) {
100+
Log(`Search Ended for Group '${groupName}' with result '${JSON.stringify(result)}'`)
101+
102+
if (result?.status !== 0 || result == null || result == undefined) {
101103
return reject(result.status);
102104
}
103105

@@ -109,7 +111,7 @@ async function SearchAllAsyncNoExceptionHandling(groupName: string): SearchAllRe
109111
});
110112

111113
response.on('error', (err: any) => {
112-
Log('error: ' + err.message);
114+
LogError(`Search Errored for Group '${groupName}': ${JSON.stringify(err)}`);
113115
return reject();
114116
});
115117

0 commit comments

Comments
 (0)