diff --git a/.gitignore b/.gitignore index 89f89cc..7c0ac3c 100644 --- a/.gitignore +++ b/.gitignore @@ -115,4 +115,6 @@ packages **/packages bin/packages -.idea \ No newline at end of file +.idea + +logs/**/*.txt \ No newline at end of file diff --git a/bin/server.dart b/bin/server.dart index c6ce22b..8de3ecc 100644 --- a/bin/server.dart +++ b/bin/server.dart @@ -1,7 +1,9 @@ import 'dart:async'; import 'dart:io'; import 'package:angel/angel.dart'; +import 'package:angel_diagnostics/angel_diagnostics.dart'; import 'package:angel_framework/angel_framework.dart'; +import 'package:intl/intl.dart'; main() async { runZoned(startServer, onError: onError); @@ -9,11 +11,12 @@ main() async { startServer() async { Angel app = await createServer(); + DateFormat dateFormat = new DateFormat("y-MM-dd"); InternetAddress host = new InternetAddress(app.properties['host']); int port = app.properties['port']; + var now = new DateTime.now(); - await app.startServer(host, port); - print("Angel server listening on ${host.address}:${port}"); + await new DiagnosticsServer(app, new File("logs/${dateFormat.format(now)}.txt")).startServer(host, port); } onError(error, [StackTrace stackTrace]) { diff --git a/logs/README.md b/logs/README.md new file mode 100644 index 0000000..cbc041e --- /dev/null +++ b/logs/README.md @@ -0,0 +1,2 @@ +# Logs +This folder contains logs from each day. Once the server is started, it creates a log in this directory. \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 08aa117..811fe43 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,6 +7,7 @@ publish_to: none dependencies: angel_auth: ^1.0.0-dev angel_configuration: ^1.0.0-dev + angel_diagnostics: ^1.0.0-dev angel_framework: ^1.0.0-dev angel_mongo: ^1.0.0-dev angel_mustache: ^1.0.0-dev