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

Runtime Logger Questions #133

Open
cwalton opened this issue Jul 19, 2024 · 1 comment
Open

Runtime Logger Questions #133

cwalton opened this issue Jul 19, 2024 · 1 comment

Comments

@cwalton
Copy link

cwalton commented Jul 19, 2024

While trying out the new runtime logger, i'm seeing a couple of things I wanted to ask about.

  1. When importing into a page /src/pages/index.astro
    import { logger } from '@it-astro:logger'

I get the following error in VS Code:
Cannot find module '@it-astro:logger' or its corresponding type declarations.ts(2307)

I can use the logger functions (logger.info, etc...) but that error is bothersome.

=====

  1. All of the logger functions seem to work, BUT the logger.debug statements are only visible when running astro dev --verbose. Seems odd.

I've tried to use logger.options to set a different default level, but that didn't work either.
It would be great to get the debug logs working without the very very verbose --verbose option.

=====

  1. Bonus:
    It looks like we can even use the fork command to create a custom logger (Great!), but when doing so, it loses the source of the event in the emitted log. It would be great if that was on the roadmap as well as adding the logger.table function, which I think is highly underutilized.
@Fryuni
Copy link
Owner

Fryuni commented Jul 20, 2024

Hey! Thank you for opening this.

  1. When importing into a page /src/pages/index.astro
    import { logger } from '@it-astro:logger'

I get the following error in VS Code: Cannot find module '@it-astro:logger' or its corresponding type declarations.ts(2307)

I can use the logger functions (logger.info, etc...) but that error is bothersome.

That is strange. I just tried VSCode on a plain, simple project (using the minimal template) and got the types correctly. I use NeoVim and it is also working fine, but that is expected since both use the same language server.

Running astro check also validates the types correctly, as shown on here.

Can you share your tsconfig.json file and your astro.config.mjs?
Which version of Astro are you using?

  1. All of the logger functions seem to work, BUT the logger.debug statements are only visible when running astro dev --verbose. Seems odd.

I've tried to use logger.options to set a different default level, but that didn't work either. It would be great to get the debug logs working without the very very verbose --verbose option.

That is as intended. The library aims to expose Astro's AstroIntegrationLogger at runtime. It behaves the same as the logger on the integrations, so behavior is just coming from Astro itself.

You can open a discussion on Astro's roadmap repo with a proposal of alternative behaviors.

  1. Bonus:
    It looks like we can even use the fork command to create a custom logger (Great!), but when doing so, it loses the source of the event in the emitted log.

I don't understand what you mean by "loses the source of the event". Can you elaborate on that?

It would be great if that was on the roadmap as well as adding the logger.table function, which I think is highly underutilized.

As mentioned above, the lib is not intended to deviate from Astro's logger. You can propose this on Astro itself 😄

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

No branches or pull requests

2 participants