GoogleCloudPlatform / functions-framework-dart

FaaS (Function as a service) framework for writing portable Dart functions
https://pub.dev/packages/functions_framework
Apache License 2.0
537 stars 54 forks source link

Logging recommendation? #248

Closed jimmyff closed 2 years ago

jimmyff commented 3 years ago

What is the recommended way to log debug etc? srdout or some sort of shelf middleware?

In this example if you specify a return type then you get a second param RequestContext which providers access to .logger(...)

But if you're just using the basic shelf request, then you don't get a RequestContext. Although this code here looks like there is some sort of support for logging from a client but I'm not sure where that logger is getting assigned.

Thanks

kevmoo commented 2 years ago

You can make your function signature look like this

https://github.com/GoogleCloudPlatform/functions-framework-dart/blob/2d9ebe336d6f006b795033b4ceaaa6d600638522/integration_test/lib/functions.dart#L115

And you'll get access to the logger!