-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathlog_custom_schema.mjs
More file actions
33 lines (28 loc) · 997 Bytes
/
log_custom_schema.mjs
File metadata and controls
33 lines (28 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* eslint-disable no-console */
import { PangeaConfig, AuditService, PangeaErrors } from "pangea-node-sdk";
const token = process.env.PANGEA_AUDIT_CUSTOM_SCHEMA_TOKEN;
const config = new PangeaConfig({ domain: process.env.PANGEA_DOMAIN });
const audit = new AuditService(token, config);
(async () => {
const msg = "node-sdk-custom-schema-example";
const data = {
message: msg,
field_int: 1,
field_bool: true,
field_str_short: "node-sdk-no-signed",
field_str_long:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed lacinia, orci eget commodo commodo non.",
field_time: new Date(Date.now()).toISOString(),
};
try {
console.log("Logging: %s", data.message);
const logResponse = await audit.log(data, { verbose: true });
console.log("Response: %s", logResponse.result);
} catch (err) {
if (err instanceof PangeaErrors.APIError) {
console.log(err.summary, err.pangeaResponse);
} else {
throw err;
}
}
})();