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

Feature: Bundle logger #733

Open
1 task done
hirasso opened this issue Jul 20, 2023 · 2 comments
Open
1 task done

Feature: Bundle logger #733

hirasso opened this issue Jul 20, 2023 · 2 comments
Milestone

Comments

@hirasso
Copy link
Member

hirasso commented Jul 20, 2023

The problem
@swup/debug-plugin has a few limitations that are hard to change without breaking changes, the biggest being that it expexts a fixed amount of arguments (message and object).

I'd like to introduce a new global logging mechanism into Swup, that consumers and plugins could make use of out of the box. I'd propose consola as the logging library.

The consumer imports the logger instance as a named import and injects it into swup:

import Swup, { logger } from "swup";
new Swup({ logger });

Plugins can now call the logger:

this.swup.logger?.info("plugin initialized");

Pros

  • Shouldn't increase bundle size when not used
  • Unified logging interface without the current limitations of @swup/debug-plugin

Limitations

UMD builds would need to use consola directly.

Alternatives considered

Separate logging implementation on the plugin level. Could become cumbersome quickly.

How important is this feature to you?

  • Nice to have
@daun
Copy link
Member

daun commented Jul 20, 2023

Could there be some way of sticking with the debug plugin? I like the Logger class a bit more, but it'd be nice to have some continuity in how everything in swup is handled with plugins.

@hirasso
Copy link
Member Author

hirasso commented Jul 20, 2023

Yea, makes sense to stick to the debug plugin if possible @daun.

Anyways, we can put a pin in this for now, no need to introduce this for swup@4.

@daun daun added the v5 label Jul 30, 2023
@daun daun added this to the v5 milestone Feb 20, 2024
@daun daun added enhancement and removed v5 labels Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants