Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sdk)!: remove logger #2060

Merged
merged 5 commits into from
Apr 13, 2023
Merged

feat(sdk)!: remove logger #2060

merged 5 commits into from
Apr 13, 2023

Conversation

eladb
Copy link
Contributor

@eladb eladb commented Apr 13, 2023

The Logger resource basically doesn't add value, only complexity. It is a great example of redundant future proofing, so let's just get rid of it and make the word a better place! We can always introduce it later when use cases are clearer.

Let me explain: the only way to emit a log right now in Wing is using the log() builtin function, which is jsified as a console.log() statement (both preflight and inflight). Now, we hijacked console.log in our runtime environments and mapped it to the standard logger of that environment.

In the cloud (e.g. AWS Lambda), the "standard logger" is basically console.log(), so basically the implementation of the logger for these environments is a "no-op".

In the simulator, since #1879, we can listen to console.xxx events that come from the VM, and map them directly to the simulator trace system, so there's no need to hijack console.log here as well.

All in all, doctor says it's a classic (and severe) case of future proofing, where we get the exact same behavior with much less complexity and code to maintain (over 700 lines of code are not needed) *== GOODNESS.

Misc

node-fetch@3 is an ESM-only module and cannot be imported into our VM (damn!). In the meantime, I've downgraded it to 2.x and opened a bug: #2059

BREAKING CHANGE: The Logger resource is no longer available.

By submitting this pull request, I confirm that my contribution is made under the terms of the Monada Contribution License.

The `Logger` resource basically doesn't add value, only complexity. It is a great example of redundant future proofing, so let's just get rid of it and make the word a better place! We can always introduce it later when use cases are clearer.

Let me explain: the only way to emit a log right now in Wing is using the `log()` builtin function, which is jsified as a `console.log()` statement (both preflight and inflight). Now, we hijacked `console.log` in our runtime environments and mapped it to the standard logger of that environment.

In the cloud (e.g. AWS Lambda), the "standard logger" is basically `console.log()`, so basically the implementation of the logger for these environments is a "no-op".

In the simulator, since #1879, we can listen to `console.xxx` events that come from the VM, and map them directly to the simulator trace system, so there's no need to hijack `console.log` here as well.

All in all, doctor says it's a classic (and severe) case of future proofing, where we get the exact same behavior with much less complexity and code to maintain (over 700 lines of code are not needed) ***== GOODNESS**.

## Misc

`node-fetch@3` is an ESM-only module and cannot be imported into our VM (damn!). In the meantime, I've downgraded it to 2.x and opened a bug: #2059
@eladb eladb requested a review from a team as a code owner April 13, 2023 09:28
@eladb eladb changed the title feat(sdk): remove logger feat!(sdk): remove logger Apr 13, 2023
@eladb eladb changed the title feat!(sdk): remove logger feat(sdk)!: remove logger Apr 13, 2023
Signed-off-by: monada-bot[bot] <monabot@monada.co>
Copy link
Contributor

@staycoolcall911 staycoolcall911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good (1 minor comment). I went ahead and closed #618, #619, #1388.

libs/wingsdk/src/target-sim/function.inflight.ts Outdated Show resolved Hide resolved
@mergify
Copy link
Contributor

mergify bot commented Apr 13, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 798870d into main Apr 13, 2023
@mergify mergify bot deleted the eladb/remove-logger branch April 13, 2023 12:56
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants