Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Unified Diff: runtime/bin/vmservice/server.dart

Issue 2715423002: Add SILENT_OBSERVATORY environment variable to Observatory web server (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/server.dart
diff --git a/runtime/bin/vmservice/server.dart b/runtime/bin/vmservice/server.dart
index 020badbefd471798b5a1679b77425672b8a9514a..c789dcf26abcb7d9b2234bf989fc210258eb71ab 100644
--- a/runtime/bin/vmservice/server.dart
+++ b/runtime/bin/vmservice/server.dart
@@ -4,6 +4,17 @@
part of vmservice_io;
+final bool silentObservatory =
+ const bool.fromEnvironment('SILENT_OBSERVATORY');
+
+void serverPrint(String s) {
+ if (silentObservatory) {
+ // We've been requested to be silent.
+ return;
+ }
+ print(s);
+}
+
class WebSocketClient extends Client {
static const int PARSE_ERROR_CODE = 4000;
static const int BINARY_MESSAGE_ERROR_CODE = 4001;
@@ -60,9 +71,9 @@ class WebSocketClient extends Client {
socket.addUtf8Text(cstring);
}
} catch (e, st) {
- print("Ignoring error posting over WebSocket.");
- print(e);
- print(st);
+ serverPrint("Ignoring error posting over WebSocket.");
+ serverPrint(e);
+ serverPrint(st);
}
}
@@ -292,8 +303,8 @@ class Server {
var message = new Message.fromUri(client, request.uri);
client.onMessage(null, message);
} catch (e) {
- print('Unexpected error processing HTTP request uri: '
- '${request.uri}\n$e\n');
+ serverPrint('Unexpected error processing HTTP request uri: '
+ '${request.uri}\n$e\n');
rethrow;
}
}
@@ -319,13 +330,13 @@ class Server {
}
_server = await HttpServer.bind(address, _port);
_server.listen(_requestHandler, cancelOnError: true);
- print('Observatory listening on $serverAddress');
+ serverPrint('Observatory listening on $serverAddress');
// Server is up and running.
_notifyServerState(serverAddress.toString());
onServerAddressChange('$serverAddress');
return this;
} catch (e, st) {
- print('Could not start Observatory HTTP server:\n$e\n$st\n');
+ serverPrint('Could not start Observatory HTTP server:\n$e\n$st\n');
_notifyServerState("");
onServerAddressChange(null);
return this;
@@ -348,14 +359,14 @@ class Server {
// Shutdown HTTP server and subscription.
Uri oldServerAddress = serverAddress;
return cleanup(forced).then((_) {
- print('Observatory no longer listening on $oldServerAddress');
+ serverPrint('Observatory no longer listening on $oldServerAddress');
_server = null;
_notifyServerState("");
onServerAddressChange(null);
return this;
}).catchError((e, st) {
_server = null;
- print('Could not shutdown Observatory HTTP server:\n$e\n$st\n');
+ serverPrint('Could not shutdown Observatory HTTP server:\n$e\n$st\n');
_notifyServerState("");
onServerAddressChange(null);
return this;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698