ibm-cloud-sdk-core 3.1.0 → 3.2.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [3.2.0](https://github.com/IBM/node-sdk-core/compare/v3.1.0...v3.2.0) (2022-10-12)
2
+
3
+
4
+ ### Features
5
+
6
+ * add method `getNewLogger` to public API ([#210](https://github.com/IBM/node-sdk-core/issues/210)) ([07b99de](https://github.com/IBM/node-sdk-core/commit/07b99def47a0eb5fcb1ab3d88b2eb3bd271b8819))
7
+
1
8
  # [3.1.0](https://github.com/IBM/node-sdk-core/compare/v3.0.1...v3.1.0) (2022-07-28)
2
9
 
3
10
 
@@ -0,0 +1,30 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [ibm-cloud-sdk-core](./ibm-cloud-sdk-core.md) &gt; [getNewLogger](./ibm-cloud-sdk-core.getnewlogger.md)
4
+
5
+ ## getNewLogger() function
6
+
7
+ Return a new logger, formatted with a particular name. The logging functions, in order of increasing verbosity, are: `error`<!-- -->, `warn`<!-- -->, `info`<!-- -->, `verbose`<!-- -->, and `debug`<!-- -->.
8
+
9
+ The logger will be an instance of the `debug` package and utilizes its support for configuration with environment variables.
10
+
11
+ Additionally, the logger will be turned on automatically if the "NODE\_DEBUG" environment variable is set to "axios".
12
+
13
+ <b>Signature:</b>
14
+
15
+ ```typescript
16
+ export declare function getNewLogger(moduleName: string): SDKLogger;
17
+ ```
18
+
19
+ ## Parameters
20
+
21
+ | Parameter | Type | Description |
22
+ | --- | --- | --- |
23
+ | moduleName | string | the namespace for the logger. The name will appear in the logs and it will be the name used for configuring the log level. |
24
+
25
+ <b>Returns:</b>
26
+
27
+ [SDKLogger](./ibm-cloud-sdk-core.sdklogger.md)
28
+
29
+ {<!-- -->SDKLogger<!-- -->} the new logger
30
+
@@ -44,6 +44,7 @@
44
44
  | [getCurrentTime()](./ibm-cloud-sdk-core.getcurrenttime.md) | Get the current time |
45
45
  | [getFormat(params, formats)](./ibm-cloud-sdk-core.getformat.md) | Returns the first match from formats that is key the params map otherwise null |
46
46
  | [getMissingParams(params, requires)](./ibm-cloud-sdk-core.getmissingparams.md) | Validates that all required params are provided |
47
+ | [getNewLogger(moduleName)](./ibm-cloud-sdk-core.getnewlogger.md) | Return a new logger, formatted with a particular name. The logging functions, in order of increasing verbosity, are: <code>error</code>, <code>warn</code>, <code>info</code>, <code>verbose</code>, and <code>debug</code>.<!-- -->The logger will be an instance of the <code>debug</code> package and utilizes its support for configuration with environment variables.<!-- -->Additionally, the logger will be turned on automatically if the "NODE\_DEBUG" environment variable is set to "axios". |
47
48
  | [getQueryParam(urlStr, param)](./ibm-cloud-sdk-core.getqueryparam.md) | Return a query parameter value from a URL |
48
49
  | [isEmptyObject(obj)](./ibm-cloud-sdk-core.isemptyobject.md) | |
49
50
  | [isFileData(obj)](./ibm-cloud-sdk-core.isfiledata.md) | |
@@ -70,6 +71,7 @@
70
71
  | [FileStream](./ibm-cloud-sdk-core.filestream.md) | |
71
72
  | [FileWithMetadata](./ibm-cloud-sdk-core.filewithmetadata.md) | |
72
73
  | [IamRequestOptions](./ibm-cloud-sdk-core.iamrequestoptions.md) | Configuration options for IAM token retrieval. |
74
+ | [SDKLogger](./ibm-cloud-sdk-core.sdklogger.md) | |
73
75
  | [UserOptions](./ibm-cloud-sdk-core.useroptions.md) | Configuration values for a service. |
74
76
 
75
77
  ## Namespaces
@@ -0,0 +1,11 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [ibm-cloud-sdk-core](./ibm-cloud-sdk-core.md) &gt; [SDKLogger](./ibm-cloud-sdk-core.sdklogger.md) &gt; [debug](./ibm-cloud-sdk-core.sdklogger.debug.md)
4
+
5
+ ## SDKLogger.debug property
6
+
7
+ <b>Signature:</b>
8
+
9
+ ```typescript
10
+ debug: Debugger;
11
+ ```
@@ -0,0 +1,11 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [ibm-cloud-sdk-core](./ibm-cloud-sdk-core.md) &gt; [SDKLogger](./ibm-cloud-sdk-core.sdklogger.md) &gt; [error](./ibm-cloud-sdk-core.sdklogger.error.md)
4
+
5
+ ## SDKLogger.error property
6
+
7
+ <b>Signature:</b>
8
+
9
+ ```typescript
10
+ error: Debugger;
11
+ ```
@@ -0,0 +1,11 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [ibm-cloud-sdk-core](./ibm-cloud-sdk-core.md) &gt; [SDKLogger](./ibm-cloud-sdk-core.sdklogger.md) &gt; [info](./ibm-cloud-sdk-core.sdklogger.info.md)
4
+
5
+ ## SDKLogger.info property
6
+
7
+ <b>Signature:</b>
8
+
9
+ ```typescript
10
+ info: Debugger;
11
+ ```
@@ -0,0 +1,22 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [ibm-cloud-sdk-core](./ibm-cloud-sdk-core.md) &gt; [SDKLogger](./ibm-cloud-sdk-core.sdklogger.md)
4
+
5
+ ## SDKLogger interface
6
+
7
+ <b>Signature:</b>
8
+
9
+ ```typescript
10
+ export interface SDKLogger
11
+ ```
12
+
13
+ ## Properties
14
+
15
+ | Property | Type | Description |
16
+ | --- | --- | --- |
17
+ | [debug](./ibm-cloud-sdk-core.sdklogger.debug.md) | Debugger | |
18
+ | [error](./ibm-cloud-sdk-core.sdklogger.error.md) | Debugger | |
19
+ | [info](./ibm-cloud-sdk-core.sdklogger.info.md) | Debugger | |
20
+ | [verbose](./ibm-cloud-sdk-core.sdklogger.verbose.md) | Debugger | |
21
+ | [warn](./ibm-cloud-sdk-core.sdklogger.warn.md) | Debugger | |
22
+
@@ -0,0 +1,11 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [ibm-cloud-sdk-core](./ibm-cloud-sdk-core.md) &gt; [SDKLogger](./ibm-cloud-sdk-core.sdklogger.md) &gt; [verbose](./ibm-cloud-sdk-core.sdklogger.verbose.md)
4
+
5
+ ## SDKLogger.verbose property
6
+
7
+ <b>Signature:</b>
8
+
9
+ ```typescript
10
+ verbose: Debugger;
11
+ ```
@@ -0,0 +1,11 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [ibm-cloud-sdk-core](./ibm-cloud-sdk-core.md) &gt; [SDKLogger](./ibm-cloud-sdk-core.sdklogger.md) &gt; [warn](./ibm-cloud-sdk-core.sdklogger.warn.md)
4
+
5
+ ## SDKLogger.warn property
6
+
7
+ <b>Signature:</b>
8
+
9
+ ```typescript
10
+ warn: Debugger;
11
+ ```
@@ -3402,6 +3402,51 @@
3402
3402
  ],
3403
3403
  "name": "getMissingParams"
3404
3404
  },
3405
+ {
3406
+ "kind": "Function",
3407
+ "canonicalReference": "ibm-cloud-sdk-core!getNewLogger:function(1)",
3408
+ "docComment": "/**\n * Return a new logger, formatted with a particular name. The logging functions, in order of increasing verbosity, are: `error`, `warn`, `info`, `verbose`, and `debug`.\n *\n * The logger will be an instance of the `debug` package and utilizes its support for configuration with environment variables.\n *\n * Additionally, the logger will be turned on automatically if the \"NODE_DEBUG\" environment variable is set to \"axios\".\n *\n * @param moduleName - the namespace for the logger. The name will appear in the logs and it will be the name used for configuring the log level.\n *\n * @returns {SDKLogger} the new logger\n */\n",
3409
+ "excerptTokens": [
3410
+ {
3411
+ "kind": "Content",
3412
+ "text": "export declare function getNewLogger(moduleName: "
3413
+ },
3414
+ {
3415
+ "kind": "Content",
3416
+ "text": "string"
3417
+ },
3418
+ {
3419
+ "kind": "Content",
3420
+ "text": "): "
3421
+ },
3422
+ {
3423
+ "kind": "Reference",
3424
+ "text": "SDKLogger",
3425
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger:interface"
3426
+ },
3427
+ {
3428
+ "kind": "Content",
3429
+ "text": ";"
3430
+ }
3431
+ ],
3432
+ "returnTypeTokenRange": {
3433
+ "startIndex": 3,
3434
+ "endIndex": 4
3435
+ },
3436
+ "releaseTag": "Public",
3437
+ "overloadIndex": 1,
3438
+ "parameters": [
3439
+ {
3440
+ "parameterName": "moduleName",
3441
+ "parameterTypeTokenRange": {
3442
+ "startIndex": 1,
3443
+ "endIndex": 2
3444
+ },
3445
+ "isOptional": false
3446
+ }
3447
+ ],
3448
+ "name": "getNewLogger"
3449
+ },
3405
3450
  {
3406
3451
  "kind": "Function",
3407
3452
  "canonicalReference": "ibm-cloud-sdk-core!getQueryParam:function(1)",
@@ -5243,6 +5288,157 @@
5243
5288
  ],
5244
5289
  "name": "removeSuffix"
5245
5290
  },
5291
+ {
5292
+ "kind": "Interface",
5293
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger:interface",
5294
+ "docComment": "",
5295
+ "excerptTokens": [
5296
+ {
5297
+ "kind": "Content",
5298
+ "text": "export interface SDKLogger "
5299
+ }
5300
+ ],
5301
+ "releaseTag": "Public",
5302
+ "name": "SDKLogger",
5303
+ "members": [
5304
+ {
5305
+ "kind": "PropertySignature",
5306
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger#debug:member",
5307
+ "docComment": "",
5308
+ "excerptTokens": [
5309
+ {
5310
+ "kind": "Content",
5311
+ "text": "debug: "
5312
+ },
5313
+ {
5314
+ "kind": "Reference",
5315
+ "text": "Debugger",
5316
+ "canonicalReference": "@types/debug!~debug.Debugger:interface"
5317
+ },
5318
+ {
5319
+ "kind": "Content",
5320
+ "text": ";"
5321
+ }
5322
+ ],
5323
+ "isOptional": false,
5324
+ "releaseTag": "Public",
5325
+ "name": "debug",
5326
+ "propertyTypeTokenRange": {
5327
+ "startIndex": 1,
5328
+ "endIndex": 2
5329
+ }
5330
+ },
5331
+ {
5332
+ "kind": "PropertySignature",
5333
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger#error:member",
5334
+ "docComment": "",
5335
+ "excerptTokens": [
5336
+ {
5337
+ "kind": "Content",
5338
+ "text": "error: "
5339
+ },
5340
+ {
5341
+ "kind": "Reference",
5342
+ "text": "Debugger",
5343
+ "canonicalReference": "@types/debug!~debug.Debugger:interface"
5344
+ },
5345
+ {
5346
+ "kind": "Content",
5347
+ "text": ";"
5348
+ }
5349
+ ],
5350
+ "isOptional": false,
5351
+ "releaseTag": "Public",
5352
+ "name": "error",
5353
+ "propertyTypeTokenRange": {
5354
+ "startIndex": 1,
5355
+ "endIndex": 2
5356
+ }
5357
+ },
5358
+ {
5359
+ "kind": "PropertySignature",
5360
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger#info:member",
5361
+ "docComment": "",
5362
+ "excerptTokens": [
5363
+ {
5364
+ "kind": "Content",
5365
+ "text": "info: "
5366
+ },
5367
+ {
5368
+ "kind": "Reference",
5369
+ "text": "Debugger",
5370
+ "canonicalReference": "@types/debug!~debug.Debugger:interface"
5371
+ },
5372
+ {
5373
+ "kind": "Content",
5374
+ "text": ";"
5375
+ }
5376
+ ],
5377
+ "isOptional": false,
5378
+ "releaseTag": "Public",
5379
+ "name": "info",
5380
+ "propertyTypeTokenRange": {
5381
+ "startIndex": 1,
5382
+ "endIndex": 2
5383
+ }
5384
+ },
5385
+ {
5386
+ "kind": "PropertySignature",
5387
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger#verbose:member",
5388
+ "docComment": "",
5389
+ "excerptTokens": [
5390
+ {
5391
+ "kind": "Content",
5392
+ "text": "verbose: "
5393
+ },
5394
+ {
5395
+ "kind": "Reference",
5396
+ "text": "Debugger",
5397
+ "canonicalReference": "@types/debug!~debug.Debugger:interface"
5398
+ },
5399
+ {
5400
+ "kind": "Content",
5401
+ "text": ";"
5402
+ }
5403
+ ],
5404
+ "isOptional": false,
5405
+ "releaseTag": "Public",
5406
+ "name": "verbose",
5407
+ "propertyTypeTokenRange": {
5408
+ "startIndex": 1,
5409
+ "endIndex": 2
5410
+ }
5411
+ },
5412
+ {
5413
+ "kind": "PropertySignature",
5414
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger#warn:member",
5415
+ "docComment": "",
5416
+ "excerptTokens": [
5417
+ {
5418
+ "kind": "Content",
5419
+ "text": "warn: "
5420
+ },
5421
+ {
5422
+ "kind": "Reference",
5423
+ "text": "Debugger",
5424
+ "canonicalReference": "@types/debug!~debug.Debugger:interface"
5425
+ },
5426
+ {
5427
+ "kind": "Content",
5428
+ "text": ";"
5429
+ }
5430
+ ],
5431
+ "isOptional": false,
5432
+ "releaseTag": "Public",
5433
+ "name": "warn",
5434
+ "propertyTypeTokenRange": {
5435
+ "startIndex": 1,
5436
+ "endIndex": 2
5437
+ }
5438
+ }
5439
+ ],
5440
+ "extendsTokenRanges": []
5441
+ },
5246
5442
  {
5247
5443
  "kind": "Function",
5248
5444
  "canonicalReference": "ibm-cloud-sdk-core!streamToPromise:function(1)",
package/es/index.d.ts CHANGED
@@ -24,3 +24,4 @@ export { default as qs } from './lib/querystring';
24
24
  export { default as contentType } from './lib/content-type';
25
25
  export * from './lib/stream-to-promise';
26
26
  export { unitTestUtils };
27
+ export { getNewLogger, SDKLogger } from './lib/get-new-logger';
package/es/index.js CHANGED
@@ -24,3 +24,4 @@ export { default as qs } from './lib/querystring';
24
24
  export { default as contentType } from './lib/content-type';
25
25
  export * from './lib/stream-to-promise';
26
26
  export { unitTestUtils };
27
+ export { getNewLogger } from './lib/get-new-logger';
@@ -0,0 +1,39 @@
1
+ /**
2
+ * (C) Copyright IBM Corp. 2022.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Debugger } from 'debug';
17
+ export interface SDKLogger {
18
+ error: Debugger;
19
+ warn: Debugger;
20
+ info: Debugger;
21
+ verbose: Debugger;
22
+ debug: Debugger;
23
+ }
24
+ /**
25
+ * Return a new logger, formatted with a particular name. The logging functions, in
26
+ * order of increasing verbosity, are: `error`, `warn`, `info`, `verbose`, and `debug`.
27
+ *
28
+ * The logger will be an instance of the `debug` package and utilizes its support for
29
+ * configuration with environment variables.
30
+ *
31
+ * Additionally, the logger will be turned on automatically if the "NODE_DEBUG"
32
+ * environment variable is set to "axios".
33
+ *
34
+ * @param {string} moduleName - the namespace for the logger. The name will appear in
35
+ * the logs and it will be the name used for configuring the log level.
36
+ *
37
+ * @returns {SDKLogger} the new logger
38
+ */
39
+ export declare function getNewLogger(moduleName: string): SDKLogger;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * (C) Copyright IBM Corp. 2022.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import logger from 'debug';
17
+ /**
18
+ * Return a new logger, formatted with a particular name. The logging functions, in
19
+ * order of increasing verbosity, are: `error`, `warn`, `info`, `verbose`, and `debug`.
20
+ *
21
+ * The logger will be an instance of the `debug` package and utilizes its support for
22
+ * configuration with environment variables.
23
+ *
24
+ * Additionally, the logger will be turned on automatically if the "NODE_DEBUG"
25
+ * environment variable is set to "axios".
26
+ *
27
+ * @param {string} moduleName - the namespace for the logger. The name will appear in
28
+ * the logs and it will be the name used for configuring the log level.
29
+ *
30
+ * @returns {SDKLogger} the new logger
31
+ */
32
+ export function getNewLogger(moduleName) {
33
+ const debug = logger(`${moduleName}:debug`);
34
+ const error = logger(`${moduleName}:error`);
35
+ const info = logger(`${moduleName}:info`);
36
+ const verbose = logger(`${moduleName}:verbose`);
37
+ const warn = logger(`${moduleName}:warning`);
38
+ // enable loggers if axios flag is set & mimic log levels severity
39
+ if (process.env.NODE_DEBUG === 'axios') {
40
+ debug.enabled = true;
41
+ }
42
+ if (debug.enabled) {
43
+ verbose.enabled = true;
44
+ }
45
+ if (verbose.enabled) {
46
+ info.enabled = true;
47
+ }
48
+ if (info.enabled) {
49
+ warn.enabled = true;
50
+ }
51
+ if (warn.enabled) {
52
+ error.enabled = true;
53
+ }
54
+ const newLogger = {
55
+ debug,
56
+ error,
57
+ info,
58
+ verbose,
59
+ warn,
60
+ };
61
+ return newLogger;
62
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 2021.
2
+ * (C) Copyright IBM Corp. 2019, 2022.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -13,12 +13,5 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import logger from 'debug';
17
- declare const _default: {
18
- debug: logger.Debugger;
19
- error: logger.Debugger;
20
- info: logger.Debugger;
21
- verbose: logger.Debugger;
22
- warn: logger.Debugger;
23
- };
16
+ declare const _default: import("./get-new-logger").SDKLogger;
24
17
  export default _default;
package/es/lib/logger.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 2021.
2
+ * (C) Copyright IBM Corp. 2019, 2022.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -13,33 +13,5 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import logger from 'debug';
17
- const debug = logger('ibm-cloud-sdk-core:debug');
18
- const error = logger('ibm-cloud-sdk-core:error');
19
- const info = logger('ibm-cloud-sdk-core:info');
20
- const verbose = logger('ibm-cloud-sdk-core:verbose');
21
- const warn = logger('ibm-cloud-sdk-core:warning');
22
- // enable loggers if axios flag is set & mimic log levels severity
23
- if (process.env.NODE_DEBUG === 'axios') {
24
- debug.enabled = true;
25
- }
26
- if (debug.enabled) {
27
- verbose.enabled = true;
28
- }
29
- if (verbose.enabled) {
30
- info.enabled = true;
31
- }
32
- if (info.enabled) {
33
- warn.enabled = true;
34
- }
35
- if (warn.enabled) {
36
- error.enabled = true;
37
- }
38
- // export loggers;
39
- export default {
40
- debug,
41
- error,
42
- info,
43
- verbose,
44
- warn,
45
- };
16
+ import { getNewLogger } from './get-new-logger';
17
+ export default getNewLogger('ibm-cloud-sdk-core');
@@ -8,6 +8,7 @@
8
8
 
9
9
  import { AxiosInstance } from 'axios';
10
10
  import type { CookieJar } from 'tough-cookie';
11
+ import { Debugger } from 'debug';
11
12
  import { OutgoingHttpHeaders } from 'http';
12
13
  import { Stream } from 'stream';
13
14
 
@@ -227,6 +228,9 @@ export function getMissingParams(params: {
227
228
  [key: string]: any;
228
229
  }, requires: string[]): null | Error;
229
230
 
231
+ // @public
232
+ export function getNewLogger(moduleName: string): SDKLogger;
233
+
230
234
  // @public
231
235
  function getOptions(createRequestMock: any): any;
232
236
 
@@ -346,6 +350,20 @@ export function readExternalSources(serviceName: string): any;
346
350
  // @public
347
351
  export function removeSuffix(str: string, suffix: string): string;
348
352
 
353
+ // @public (undocumented)
354
+ export interface SDKLogger {
355
+ // (undocumented)
356
+ debug: Debugger;
357
+ // (undocumented)
358
+ error: Debugger;
359
+ // (undocumented)
360
+ info: Debugger;
361
+ // (undocumented)
362
+ verbose: Debugger;
363
+ // (undocumented)
364
+ warn: Debugger;
365
+ }
366
+
349
367
  // @public
350
368
  export function streamToPromise(stream: Stream): Promise<any>;
351
369
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { AxiosInstance } from 'axios';
4
4
  import type { CookieJar } from 'tough-cookie';
5
+ import { Debugger } from 'debug';
5
6
  import { OutgoingHttpHeaders } from 'http';
6
7
  import { Stream } from 'stream';
7
8
 
@@ -719,6 +720,23 @@ export declare class BaseService {
719
720
  [key: string]: any;
720
721
  }, requires: string[]): null | Error;
721
722
 
723
+ /**
724
+ * Return a new logger, formatted with a particular name. The logging functions, in
725
+ * order of increasing verbosity, are: `error`, `warn`, `info`, `verbose`, and `debug`.
726
+ *
727
+ * The logger will be an instance of the `debug` package and utilizes its support for
728
+ * configuration with environment variables.
729
+ *
730
+ * Additionally, the logger will be turned on automatically if the "NODE_DEBUG"
731
+ * environment variable is set to "axios".
732
+ *
733
+ * @param {string} moduleName - the namespace for the logger. The name will appear in
734
+ * the logs and it will be the name used for configuring the log level.
735
+ *
736
+ * @returns {SDKLogger} the new logger
737
+ */
738
+ export declare function getNewLogger(moduleName: string): SDKLogger;
739
+
722
740
  /**
723
741
  * This method extracts the `options` property from the object passed into `createRequest`. This property is
724
742
  * an object containing all of the SDK method-specific information (like `path` and `body`) used to build a request.
@@ -1234,6 +1252,14 @@ export declare class BaseService {
1234
1252
  maxRetryInterval?: number;
1235
1253
  }
1236
1254
 
1255
+ export declare interface SDKLogger {
1256
+ error: Debugger;
1257
+ warn: Debugger;
1258
+ info: Debugger;
1259
+ verbose: Debugger;
1260
+ debug: Debugger;
1261
+ }
1262
+
1237
1263
  /**
1238
1264
  * Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer
1239
1265
  * or array of text chunks
package/index.d.ts CHANGED
@@ -24,3 +24,4 @@ export { default as qs } from './lib/querystring';
24
24
  export { default as contentType } from './lib/content-type';
25
25
  export * from './lib/stream-to-promise';
26
26
  export { unitTestUtils };
27
+ export { getNewLogger, SDKLogger } from './lib/get-new-logger';
package/index.js CHANGED
@@ -39,3 +39,5 @@ exports.qs = querystring_1.default;
39
39
  var content_type_1 = require("./lib/content-type");
40
40
  exports.contentType = content_type_1.default;
41
41
  __export(require("./lib/stream-to-promise"));
42
+ var get_new_logger_1 = require("./lib/get-new-logger");
43
+ exports.getNewLogger = get_new_logger_1.getNewLogger;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * (C) Copyright IBM Corp. 2022.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Debugger } from 'debug';
17
+ export interface SDKLogger {
18
+ error: Debugger;
19
+ warn: Debugger;
20
+ info: Debugger;
21
+ verbose: Debugger;
22
+ debug: Debugger;
23
+ }
24
+ /**
25
+ * Return a new logger, formatted with a particular name. The logging functions, in
26
+ * order of increasing verbosity, are: `error`, `warn`, `info`, `verbose`, and `debug`.
27
+ *
28
+ * The logger will be an instance of the `debug` package and utilizes its support for
29
+ * configuration with environment variables.
30
+ *
31
+ * Additionally, the logger will be turned on automatically if the "NODE_DEBUG"
32
+ * environment variable is set to "axios".
33
+ *
34
+ * @param {string} moduleName - the namespace for the logger. The name will appear in
35
+ * the logs and it will be the name used for configuring the log level.
36
+ *
37
+ * @returns {SDKLogger} the new logger
38
+ */
39
+ export declare function getNewLogger(moduleName: string): SDKLogger;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /**
3
+ * (C) Copyright IBM Corp. 2022.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var debug_1 = __importDefault(require("debug"));
22
+ /**
23
+ * Return a new logger, formatted with a particular name. The logging functions, in
24
+ * order of increasing verbosity, are: `error`, `warn`, `info`, `verbose`, and `debug`.
25
+ *
26
+ * The logger will be an instance of the `debug` package and utilizes its support for
27
+ * configuration with environment variables.
28
+ *
29
+ * Additionally, the logger will be turned on automatically if the "NODE_DEBUG"
30
+ * environment variable is set to "axios".
31
+ *
32
+ * @param {string} moduleName - the namespace for the logger. The name will appear in
33
+ * the logs and it will be the name used for configuring the log level.
34
+ *
35
+ * @returns {SDKLogger} the new logger
36
+ */
37
+ function getNewLogger(moduleName) {
38
+ var debug = debug_1.default(moduleName + ":debug");
39
+ var error = debug_1.default(moduleName + ":error");
40
+ var info = debug_1.default(moduleName + ":info");
41
+ var verbose = debug_1.default(moduleName + ":verbose");
42
+ var warn = debug_1.default(moduleName + ":warning");
43
+ // enable loggers if axios flag is set & mimic log levels severity
44
+ if (process.env.NODE_DEBUG === 'axios') {
45
+ debug.enabled = true;
46
+ }
47
+ if (debug.enabled) {
48
+ verbose.enabled = true;
49
+ }
50
+ if (verbose.enabled) {
51
+ info.enabled = true;
52
+ }
53
+ if (info.enabled) {
54
+ warn.enabled = true;
55
+ }
56
+ if (warn.enabled) {
57
+ error.enabled = true;
58
+ }
59
+ var newLogger = {
60
+ debug: debug,
61
+ error: error,
62
+ info: info,
63
+ verbose: verbose,
64
+ warn: warn,
65
+ };
66
+ return newLogger;
67
+ }
68
+ exports.getNewLogger = getNewLogger;
package/lib/logger.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 2021.
2
+ * (C) Copyright IBM Corp. 2019, 2022.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -13,12 +13,5 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import logger from 'debug';
17
- declare const _default: {
18
- debug: logger.Debugger;
19
- error: logger.Debugger;
20
- info: logger.Debugger;
21
- verbose: logger.Debugger;
22
- warn: logger.Debugger;
23
- };
16
+ declare const _default: import("./get-new-logger").SDKLogger;
24
17
  export default _default;
package/lib/logger.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * (C) Copyright IBM Corp. 2019, 2021.
3
+ * (C) Copyright IBM Corp. 2019, 2022.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -14,37 +14,6 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
17
  Object.defineProperty(exports, "__esModule", { value: true });
21
- var debug_1 = __importDefault(require("debug"));
22
- var debug = debug_1.default('ibm-cloud-sdk-core:debug');
23
- var error = debug_1.default('ibm-cloud-sdk-core:error');
24
- var info = debug_1.default('ibm-cloud-sdk-core:info');
25
- var verbose = debug_1.default('ibm-cloud-sdk-core:verbose');
26
- var warn = debug_1.default('ibm-cloud-sdk-core:warning');
27
- // enable loggers if axios flag is set & mimic log levels severity
28
- if (process.env.NODE_DEBUG === 'axios') {
29
- debug.enabled = true;
30
- }
31
- if (debug.enabled) {
32
- verbose.enabled = true;
33
- }
34
- if (verbose.enabled) {
35
- info.enabled = true;
36
- }
37
- if (info.enabled) {
38
- warn.enabled = true;
39
- }
40
- if (warn.enabled) {
41
- error.enabled = true;
42
- }
43
- // export loggers;
44
- exports.default = {
45
- debug: debug,
46
- error: error,
47
- info: info,
48
- verbose: verbose,
49
- warn: warn,
50
- };
18
+ var get_new_logger_1 = require("./get-new-logger");
19
+ exports.default = get_new_logger_1.getNewLogger('ibm-cloud-sdk-core');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ibm-cloud-sdk-core",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.",
5
5
  "main": "index.js",
6
6
  "typings": "./es/index.d.ts",
@@ -3402,6 +3402,51 @@
3402
3402
  ],
3403
3403
  "name": "getMissingParams"
3404
3404
  },
3405
+ {
3406
+ "kind": "Function",
3407
+ "canonicalReference": "ibm-cloud-sdk-core!getNewLogger:function(1)",
3408
+ "docComment": "/**\n * Return a new logger, formatted with a particular name. The logging functions, in order of increasing verbosity, are: `error`, `warn`, `info`, `verbose`, and `debug`.\n *\n * The logger will be an instance of the `debug` package and utilizes its support for configuration with environment variables.\n *\n * Additionally, the logger will be turned on automatically if the \"NODE_DEBUG\" environment variable is set to \"axios\".\n *\n * @param moduleName - the namespace for the logger. The name will appear in the logs and it will be the name used for configuring the log level.\n *\n * @returns {SDKLogger} the new logger\n */\n",
3409
+ "excerptTokens": [
3410
+ {
3411
+ "kind": "Content",
3412
+ "text": "export declare function getNewLogger(moduleName: "
3413
+ },
3414
+ {
3415
+ "kind": "Content",
3416
+ "text": "string"
3417
+ },
3418
+ {
3419
+ "kind": "Content",
3420
+ "text": "): "
3421
+ },
3422
+ {
3423
+ "kind": "Reference",
3424
+ "text": "SDKLogger",
3425
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger:interface"
3426
+ },
3427
+ {
3428
+ "kind": "Content",
3429
+ "text": ";"
3430
+ }
3431
+ ],
3432
+ "returnTypeTokenRange": {
3433
+ "startIndex": 3,
3434
+ "endIndex": 4
3435
+ },
3436
+ "releaseTag": "Public",
3437
+ "overloadIndex": 1,
3438
+ "parameters": [
3439
+ {
3440
+ "parameterName": "moduleName",
3441
+ "parameterTypeTokenRange": {
3442
+ "startIndex": 1,
3443
+ "endIndex": 2
3444
+ },
3445
+ "isOptional": false
3446
+ }
3447
+ ],
3448
+ "name": "getNewLogger"
3449
+ },
3405
3450
  {
3406
3451
  "kind": "Function",
3407
3452
  "canonicalReference": "ibm-cloud-sdk-core!getQueryParam:function(1)",
@@ -5243,6 +5288,157 @@
5243
5288
  ],
5244
5289
  "name": "removeSuffix"
5245
5290
  },
5291
+ {
5292
+ "kind": "Interface",
5293
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger:interface",
5294
+ "docComment": "",
5295
+ "excerptTokens": [
5296
+ {
5297
+ "kind": "Content",
5298
+ "text": "export interface SDKLogger "
5299
+ }
5300
+ ],
5301
+ "releaseTag": "Public",
5302
+ "name": "SDKLogger",
5303
+ "members": [
5304
+ {
5305
+ "kind": "PropertySignature",
5306
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger#debug:member",
5307
+ "docComment": "",
5308
+ "excerptTokens": [
5309
+ {
5310
+ "kind": "Content",
5311
+ "text": "debug: "
5312
+ },
5313
+ {
5314
+ "kind": "Reference",
5315
+ "text": "Debugger",
5316
+ "canonicalReference": "@types/debug!~debug.Debugger:interface"
5317
+ },
5318
+ {
5319
+ "kind": "Content",
5320
+ "text": ";"
5321
+ }
5322
+ ],
5323
+ "isOptional": false,
5324
+ "releaseTag": "Public",
5325
+ "name": "debug",
5326
+ "propertyTypeTokenRange": {
5327
+ "startIndex": 1,
5328
+ "endIndex": 2
5329
+ }
5330
+ },
5331
+ {
5332
+ "kind": "PropertySignature",
5333
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger#error:member",
5334
+ "docComment": "",
5335
+ "excerptTokens": [
5336
+ {
5337
+ "kind": "Content",
5338
+ "text": "error: "
5339
+ },
5340
+ {
5341
+ "kind": "Reference",
5342
+ "text": "Debugger",
5343
+ "canonicalReference": "@types/debug!~debug.Debugger:interface"
5344
+ },
5345
+ {
5346
+ "kind": "Content",
5347
+ "text": ";"
5348
+ }
5349
+ ],
5350
+ "isOptional": false,
5351
+ "releaseTag": "Public",
5352
+ "name": "error",
5353
+ "propertyTypeTokenRange": {
5354
+ "startIndex": 1,
5355
+ "endIndex": 2
5356
+ }
5357
+ },
5358
+ {
5359
+ "kind": "PropertySignature",
5360
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger#info:member",
5361
+ "docComment": "",
5362
+ "excerptTokens": [
5363
+ {
5364
+ "kind": "Content",
5365
+ "text": "info: "
5366
+ },
5367
+ {
5368
+ "kind": "Reference",
5369
+ "text": "Debugger",
5370
+ "canonicalReference": "@types/debug!~debug.Debugger:interface"
5371
+ },
5372
+ {
5373
+ "kind": "Content",
5374
+ "text": ";"
5375
+ }
5376
+ ],
5377
+ "isOptional": false,
5378
+ "releaseTag": "Public",
5379
+ "name": "info",
5380
+ "propertyTypeTokenRange": {
5381
+ "startIndex": 1,
5382
+ "endIndex": 2
5383
+ }
5384
+ },
5385
+ {
5386
+ "kind": "PropertySignature",
5387
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger#verbose:member",
5388
+ "docComment": "",
5389
+ "excerptTokens": [
5390
+ {
5391
+ "kind": "Content",
5392
+ "text": "verbose: "
5393
+ },
5394
+ {
5395
+ "kind": "Reference",
5396
+ "text": "Debugger",
5397
+ "canonicalReference": "@types/debug!~debug.Debugger:interface"
5398
+ },
5399
+ {
5400
+ "kind": "Content",
5401
+ "text": ";"
5402
+ }
5403
+ ],
5404
+ "isOptional": false,
5405
+ "releaseTag": "Public",
5406
+ "name": "verbose",
5407
+ "propertyTypeTokenRange": {
5408
+ "startIndex": 1,
5409
+ "endIndex": 2
5410
+ }
5411
+ },
5412
+ {
5413
+ "kind": "PropertySignature",
5414
+ "canonicalReference": "ibm-cloud-sdk-core!SDKLogger#warn:member",
5415
+ "docComment": "",
5416
+ "excerptTokens": [
5417
+ {
5418
+ "kind": "Content",
5419
+ "text": "warn: "
5420
+ },
5421
+ {
5422
+ "kind": "Reference",
5423
+ "text": "Debugger",
5424
+ "canonicalReference": "@types/debug!~debug.Debugger:interface"
5425
+ },
5426
+ {
5427
+ "kind": "Content",
5428
+ "text": ";"
5429
+ }
5430
+ ],
5431
+ "isOptional": false,
5432
+ "releaseTag": "Public",
5433
+ "name": "warn",
5434
+ "propertyTypeTokenRange": {
5435
+ "startIndex": 1,
5436
+ "endIndex": 2
5437
+ }
5438
+ }
5439
+ ],
5440
+ "extendsTokenRanges": []
5441
+ },
5246
5442
  {
5247
5443
  "kind": "Function",
5248
5444
  "canonicalReference": "ibm-cloud-sdk-core!streamToPromise:function(1)",
@@ -8,6 +8,7 @@
8
8
 
9
9
  import { AxiosInstance } from 'axios';
10
10
  import type { CookieJar } from 'tough-cookie';
11
+ import { Debugger } from 'debug';
11
12
  import { OutgoingHttpHeaders } from 'http';
12
13
  import { Stream } from 'stream';
13
14
 
@@ -227,6 +228,9 @@ export function getMissingParams(params: {
227
228
  [key: string]: any;
228
229
  }, requires: string[]): null | Error;
229
230
 
231
+ // @public
232
+ export function getNewLogger(moduleName: string): SDKLogger;
233
+
230
234
  // @public
231
235
  function getOptions(createRequestMock: any): any;
232
236
 
@@ -346,6 +350,20 @@ export function readExternalSources(serviceName: string): any;
346
350
  // @public
347
351
  export function removeSuffix(str: string, suffix: string): string;
348
352
 
353
+ // @public (undocumented)
354
+ export interface SDKLogger {
355
+ // (undocumented)
356
+ debug: Debugger;
357
+ // (undocumented)
358
+ error: Debugger;
359
+ // (undocumented)
360
+ info: Debugger;
361
+ // (undocumented)
362
+ verbose: Debugger;
363
+ // (undocumented)
364
+ warn: Debugger;
365
+ }
366
+
349
367
  // @public
350
368
  export function streamToPromise(stream: Stream): Promise<any>;
351
369