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

Question about logging #473

Closed mark-dropbear closed 3 months ago

mark-dropbear commented 3 months ago

Hi, Apologies if this was a dumb question but I couldn't figure this out from the documentation or looking at the code unfortunately so I decided to ask here instead.

How would I go about setting up a Cloud Function that implements a generic HTTP server but has access to Cloud Run's structured logging. I kind of expected something like this:

import 'dart:async';

import 'package:functions_framework/functions_framework.dart';
import 'package:shelf/shelf.dart';

@CloudFunction()
FutureOr<Response> function(Request request, RequestLogger logger) {
  logger.info('Hello, Logging?');
  return Response.ok('Hello, World!');
}

But that only gets me this error: image

mark-dropbear commented 3 months ago

Closing. It was a stale build runner cache causing issues. Apologies.