Runtime Logger
Astro provides a logger (typed AstroIntegrationLogger
) configured for each integration on all the official integration hooks. But this logger is only accessible on the code configuring the integration, not for any runtime modules defined by it.
This package allows you to access Astro’s built-in logger from the runtime of a project.
Installing the dependency
For projects
Projects can install the integration included in this package to get a runtime logger for each file in their project:
With that integration installed, you can import a logger from @it-astro:logger
from anywhere in your project. The returned logger will be named after the file that imported it.
For integrations
Integrations can register their own loggers to be used by the runtime using the runtimeLogger
utility.
The utility takes the parameters of astro:config:setup
and the name of the module where the logger will be made available at runtime:
With that in place, your runtime code can now access the logger by importing the generated module @it-astro:logger:<name>
:
License
Astro Runtime Logger is available under the MIT license.