You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(cli): use CliIoHost as logger everywhere (#32708)
### Related to #32346
### Reason for this change
Capture all logs across the CLI as IoMessages so that when we allow
customers to use the CDK Core functionality programmatically, these logs
are delivered to the customers as messages and now just swallowed across
the CLI.
### Description of changes
Prevented access to `log()` and `formatLogMessage()`. Now the only ways
to log something properly are either through the exported log functions
(which is how everyone was doing it anyway), or through
`CliIoHost.notify()` directly.
CliIoHost is now exposed as a global singleton which is currently only
directly exclusively used in `logging.ts` but is effectively used
everywhere as all logging functions inevitably call `CliIoHost.notify()`
All logging functions now optionally support the following input types
```ts
error(`operation failed: ${e}`) // infers default error code `TOOLKIT_0000`
error('operation failed: %s', e) // infers default error code `TOOLKIT_0000`
error({ message: 'operation failed', code: 'SDK_0001' }) // specifies error code `SDK_0001`
error({ message: 'operation failed: %s', code: 'SDK_0001' }, e) // specifies error code `SDK_0001`
```
and everything is now translated into an `IoMessage` and calls
`CliIoHost.notify()` from these logging functions. Nothing currently
specifies any message code so it's all the generic _0000, _1000, _2000
### Description of how you validated changes
added and updated unit tests
### Checklist
- [x] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
---------
Co-authored-by: Kaizen Conroy <[email protected]>
Co-authored-by: Momo Kornher <[email protected]>
0 commit comments