From e86132dd0c11e024f8cec3d4755a2c69668c45c9 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 2 May 2018 07:30:49 -0700 Subject: [PATCH] Memcache tweak (#76) * cleanup .gitignore * Indent and format the stacktrace on memcache connect failure --- .gitignore | 9 ++------- CHANGELOG.md | 4 ++++ lib/src/appengine_internal.dart | 9 ++++++++- pubspec.yaml | 3 ++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 7a2e8dd9..6c862f08 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,4 @@ -.buildlog -.DS_Store -.idea +.dart_tool +.packages .pub/ -.settings/ -build/ -packages pubspec.lock -.packages diff --git a/CHANGELOG.md b/CHANGELOG.md index a66fe377..20413ab4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.4 + +* Improve output logging when memcache connections fail. + ## 0.4.3+1 * When logging requests, the `appengine.googleapis.com/trace_id` label diff --git a/lib/src/appengine_internal.dart b/lib/src/appengine_internal.dart index 47477672..63948c59 100644 --- a/lib/src/appengine_internal.dart +++ b/lib/src/appengine_internal.dart @@ -5,6 +5,7 @@ library appengine.internal; import 'dart:async'; +import 'dart:convert'; import 'dart:io'; import 'package:gcloud/datastore.dart' as datastore; @@ -17,6 +18,7 @@ import 'package:http/http.dart' as http; import 'package:memcache/memcache.dart' as memcache; import 'package:memcache/memcache_raw.dart' as memcache_raw; import 'package:path/path.dart' as p; +import 'package:stack_trace/stack_trace.dart'; import 'errors.dart' as errors; import 'logging.dart' as logging; @@ -296,8 +298,13 @@ Future _tryMemcacheInstance( return memcacheService; } } catch (e, stack) { + var stackIndented = LineSplitter + .split(Trace.format(stack, terse: true)) + .map((l) => ' $l') + .join('\n'); + logging.warning('Could not connect to memcache instance at $host:$port\n' - '$e\n$stack'); + '$e\n$stackIndented'); } // We were unable to connect to a memcached server running on localhost, so diff --git a/pubspec.yaml b/pubspec.yaml index 2329babd..d5d15c55 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appengine -version: 0.4.3+1 +version: 0.4.4-dev author: Dart Team description: Support for using Dart as a custom runtime on Google App Engine Flexible Environment homepage: https://github.com/dart-lang/appengine @@ -16,5 +16,6 @@ dependencies: memcache: '^0.2.1+1' path: '^1.2.0' protobuf: '^0.5.0' + stack_trace: '^1.9.0' dev_dependencies: test: '^0.12.18+1'