routed_logging 0.2.1 copy "routed_logging: ^0.2.1" to clipboard
routed_logging: ^0.2.1 copied to clipboard

HTTP logging provider and request logger helpers for Routed.

routed_logging #

HTTP logging provider and request logger helpers for Routed.

Install #

dependencies:
  routed: ^0.5.0
  routed_core: ^0.5.0
  routed_logging: ^0.2.0

Initialize and use #

Call registerRoutedProviders() when using the routed facade so routed.logging is included. A slim engine must add LoggingServiceProvider explicitly:

import 'package:routed_core/routed_core.dart';
import 'package:routed_logging/routed_logging.dart';

Future<void> main() async {
  final engine = await Engine.create(
    providers: [
      ...Engine.defaultProviders,
      LoggingServiceProvider(),
    ],
  );

  engine.get('/health', (ctx) {
    ctx.logger.info('health check');
    return ctx.json({'ok': true});
  });

  await engine.serve(port: 8080);
}

Provider configuration is supplied with the typed LoggingConfig constructor, for example LoggingServiceProvider(LoggingConfig(errorsOnly: true)). There is no YAML or dotted-key configuration path. If you use the package's provider catalogue directly, call registerRoutedLoggingProviders() before engine creation; otherwise construct LoggingServiceProvider in the provider list as shown above.

0
likes
140
points
600
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

HTTP logging provider and request logger helpers for Routed.

Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

www.buymeacoffee.com

License

MIT (license)

Dependencies

contextual, routed_core

More

Packages that depend on routed_logging