@uoa/lambda-tracing 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ReleaseSteps.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Steps to release package to npm
2
2
  1. `npm login`
3
3
  2. `npm version <new version>`
4
- 3. Push to git to sync new tags
5
- 4. `npm publish --access=public --otp=<2FA code>`
4
+ 3. Update changelog.md & commit the changes
5
+ 4. Push to git to sync new tags
6
+ 5. `npm publish --access=public --otp=<2FA code>`
6
7
 
7
8
  # Testing locally before release
8
9
  1. `npm pack`
package/UoaLogger.ts CHANGED
@@ -64,26 +64,28 @@ export class UoaLogger {
64
64
  public audit(auditInformation: AuditInformation, message?: string): void {
65
65
  // Initialize logMessage with mandatory fields
66
66
  let logMessage: string =
67
- `accessedBy:${auditInformation.accessedBy.replace(/\s/g, '')} ` +
68
- `action:${auditInformation.action.toString().replace(/\s/g, '')} ` +
69
- `owner:${auditInformation.ownerId.replace(/\s/g, '')} ` +
70
- `resourceType:${auditInformation.resourceType.replace(/\s/g, '')}`;
71
-
72
- // Add optional fields if they exist
73
- if (auditInformation.application) {
74
- logMessage = `application:${auditInformation.application.replace(/\s/g, '')} ` + logMessage;
75
- }
76
- if (auditInformation.resourceId) {
77
- logMessage += ` resourceId:${auditInformation.resourceId.replace(/\s/g, '')}`;
78
- }
79
-
67
+ `application:${
68
+ auditInformation.application
69
+ ? auditInformation.application.replace(/\s/g, "")
70
+ : "-"
71
+ } ` +
72
+ `accessedBy:${auditInformation.accessedBy.replace(/\s/g, "")} ` +
73
+ `action:${auditInformation.action.toString().replace(/\s/g, "")} ` +
74
+ `owner:${auditInformation.ownerId.replace(/\s/g, "")} ` +
75
+ `resourceType:${auditInformation.resourceType.replace(/\s/g, "")} ` +
76
+ `resourceId:${
77
+ auditInformation.resourceId
78
+ ? auditInformation.resourceId.replace(/\s/g, "")
79
+ : "-"
80
+ }`;
81
+
80
82
  // Append additional message if provided
81
83
  if (message) {
82
- logMessage += ` ${message}`;
84
+ logMessage += ` ${message}`;
83
85
  }
84
-
86
+
85
87
  this.logger.log("audit", logMessage);
86
- }
88
+ }
87
89
 
88
90
  /**
89
91
  * Function to log warn level messages.
package/changelog.md CHANGED
@@ -1,7 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.2.2
4
+ - Change behaviour for optional audit parameters. Instead of removing empty optional parameters, they will be present with a hyphen ("-").
5
+
6
+ ## 2.2.1
7
+ - Fix formatting in readme
8
+
3
9
  ## 2.2.0
4
10
  - Added audit level to logger
11
+ - The logger debug, info, warn, and error functions now require a string input
5
12
 
6
13
  ## 2.1.2
7
14
  - Updated XML response parsing to include attribute tags
package/dist/UoaLogger.js CHANGED
@@ -30,17 +30,16 @@ class UoaLogger {
30
30
  */
31
31
  audit(auditInformation, message) {
32
32
  // Initialize logMessage with mandatory fields
33
- let logMessage = `accessedBy:${auditInformation.accessedBy.replace(/\s/g, '')} ` +
34
- `action:${auditInformation.action.toString().replace(/\s/g, '')} ` +
35
- `owner:${auditInformation.ownerId.replace(/\s/g, '')} ` +
36
- `resourceType:${auditInformation.resourceType.replace(/\s/g, '')}`;
37
- // Add optional fields if they exist
38
- if (auditInformation.application) {
39
- logMessage = `application:${auditInformation.application.replace(/\s/g, '')} ` + logMessage;
40
- }
41
- if (auditInformation.resourceId) {
42
- logMessage += ` resourceId:${auditInformation.resourceId.replace(/\s/g, '')}`;
43
- }
33
+ let logMessage = `application:${auditInformation.application
34
+ ? auditInformation.application.replace(/\s/g, "")
35
+ : "-"} ` +
36
+ `accessedBy:${auditInformation.accessedBy.replace(/\s/g, "")} ` +
37
+ `action:${auditInformation.action.toString().replace(/\s/g, "")} ` +
38
+ `owner:${auditInformation.ownerId.replace(/\s/g, "")} ` +
39
+ `resourceType:${auditInformation.resourceType.replace(/\s/g, "")} ` +
40
+ `resourceId:${auditInformation.resourceId
41
+ ? auditInformation.resourceId.replace(/\s/g, "")
42
+ : "-"}`;
44
43
  // Append additional message if provided
45
44
  if (message) {
46
45
  logMessage += ` ${message}`;
package/package.json CHANGED
@@ -1,12 +1,27 @@
1
1
  {
2
2
  "name": "@uoa/lambda-tracing",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Library for logging & distributed tracing in UoA Lambda projects",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@bitbucket.org/uoa/lambda-tracing.git"
8
8
  },
9
9
  "author": "Mitchell Faulconbridge <mitchell.faulconbridge@auckland.ac.nz>",
10
+ "contributors": [
11
+ {
12
+ "name": "Mitchell Faulconbridge",
13
+ "email": "mitchell.faulconbridge@auckland.ac.nz"
14
+ },
15
+ {
16
+ "name": "Wenlai Wang",
17
+ "email": "w.wang@auckland.ac.nz"
18
+ },
19
+ {
20
+ "name": "Osama Kashif",
21
+ "email": "osama.kashif@auckland.ac.nz",
22
+ "url": "https://www.linkedin.com/in/osamakashif"
23
+ }
24
+ ],
10
25
  "license": "MIT",
11
26
  "homepage": "https://bitbucket.org/uoa/lambda-tracing#readme",
12
27
  "keywords": [
package/readme.md CHANGED
@@ -126,8 +126,7 @@ logger.audit({application: "applicationName", action: "read", resourceId: "12345
126
126
  ```
127
127
  Will produce the following log message:
128
128
  ```text
129
- 2024-04-12T00:58:05.321Z [-] AUDIT src.controller.person-controller - [[[TraceId,SpanId,Info]]] application:applicationName accessedBy:upi1234 action:read owner:upi5678
130
- resourceType:personalDetails resourceId:123456789 Additional useful info
129
+ 2024-04-12T00:58:05.321Z [-] AUDIT src.controller.person-controller - [[[TraceId,SpanId,Info]]] application:applicationName accessedBy:upi1234 action:read owner:upi5678 resourceType:personalDetails resourceId:123456789 Additional useful info
131
130
  ```
132
131
 
133
132
  ### Distributed Tracing