Logging events for a component
The Storefront logger is made available to components, and to user-defined services. For usage instructions, see the loglevel
documentation.
Within a component, the logger is available via the log
property of the component instance.
@tag( 'my-cool-component' )
export class MyCoolComponent {
...
onMount() {
this.log.error( 'Whoops, something went wrong' );
}
...
}
Within a service, the logger can be accessed as a property of the app
, which is provided at instantiation.
class MyCoolService {
constructor( app ) {
this.app = app;
}
fetchData() {
this.app.log.debug( 'Fetching data' );
...
}
}