/
logging.ts
32 lines (26 loc) · 1.17 KB
/
logging.ts
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
/**
* Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
* This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
*/
/**
* This is an example shows how to integrate a logger with the SDK
*/
var oci = require("oci-sdk");
var bunyan = require("bunyan");
// Integrate bunyan logger with the SDK. Make sure bunyan logger in installed.
// You can integrate with log4js, winston or any other logger as well.
var bunLog = bunyan.createLogger({ name: "LoggingExample", level: "debug" });
oci.LOG.logger = bunLog;
const provider = new oci.common.ConfigFileAuthenticationDetailsProvider();
(async () => {
const identityClient = new oci.identity.IdentityClient({
authenticationDetailsProvider: provider
});
const regions = await identityClient.listRegionSubscriptions({
tenancyId: provider.getTenantId() || ""
});
for (let i = 0; i < regions.items.length; i++) {
console.log(`Region fetched ${regions.items[i].regionName}`);
}
identityClient.close();
})();