Fixed dev logging

This commit is contained in:
thomashii 2022-01-23 13:10:50 +08:00
parent 2518e36e08
commit b55489974f
8 changed files with 46 additions and 23 deletions

View file

@ -23,6 +23,24 @@ jobs:
with:
sdk: "2.15.1"
- id: angel3_container_upgrade
name: angel3_container; Upgrade depedencies
working-directory: packages/container/angel_container
run: dart pub upgrade
- name: angel3_container; Verify formatting
working-directory: packages/container/angel_container
run: dart format --output=none --set-exit-if-changed .
# Consider passing '--fatal-infos' for slightly stricter analysis.
- name: angel3_container; Analyze source code
working-directory: packages/container/angel_container
run: dart analyze
- name: angel3_container; Run tests
working-directory: packages/container/angel_container
run: dart test
- id: angel3_framework_upgrade
name: angel3_framework; Upgrade depedencies
working-directory: packages/framework

View file

@ -26,11 +26,11 @@ void main() async {
CacheService(
database: AnonymousService(
index: ([params]) {
print('Fetched directly from the underlying service at ${new DateTime.now()}!');
print('Fetched directly from the underlying service at ${DateTime.now()}!');
return ['foo', 'bar', 'baz'];
},
read: (id, [params]) {
return {id: '$id at ${new DateTime.now()}'};
return {id: '$id at ${DateTime.now()}'};
}
),
),
@ -42,7 +42,7 @@ void main() async {
A flexible response cache for Angel3.
Use this to improve real and perceived response of Web applications, as well as to memoize expensive responses.
Use this to improve real and perceived response of Web applications, as well as to memorize expensive responses.
Supports the `If-Modified-Since` header, as well as storing the contents of response buffers in memory.

View file

@ -7,7 +7,7 @@ import 'package:logging/logging.dart';
/// A flexible response cache for Angel.
///
/// Use this to improve real and perceived response of Web applications,
/// as well as to memoize expensive responses.
/// as well as to memorize expensive responses.
class ResponseCache {
/// A set of [Patterns] for which responses will be cached.
///

View file

@ -23,11 +23,11 @@ class Container {
}
/// Determines if the container has an injection of the given type.
bool has<T>([Type? type]) {
bool has<T>([Type? t]) {
var t2 = T;
if (type != null) {
t2 = type;
} else if (T == dynamic && type == null) {
if (t != null) {
t2 = t;
} else if (T == dynamic && t == null) {
return false;
}

View file

@ -1,5 +1,9 @@
# Change Log
## 4.2.4
* Fixed issue 48. Log not working in development
## 4.2.3
* Fixed `res.json()` throwing bad state exception

View file

@ -4,7 +4,6 @@ import 'dart:io' show stderr, Cookie;
import 'package:angel3_http_exception/angel3_http_exception.dart';
import 'package:angel3_route/angel3_route.dart';
import 'package:belatuk_combinator/belatuk_combinator.dart';
import 'package:logging/logging.dart';
import 'package:stack_trace/stack_trace.dart';
import 'package:tuple/tuple.dart';
import 'core.dart';
@ -27,7 +26,7 @@ abstract class Driver<
bool isServerInitialised = false;
StreamSubscription<Request>? _sub;
final log = Logger('Driver');
//final log = Logger('Driver');
/// The function used to bind this instance to a server..
final Future<Server> Function(dynamic, int) serverGenerator;
@ -71,7 +70,7 @@ abstract class Driver<
return Future.value(_server);
});
}).catchError((error) {
log.severe('Failed to create server', error);
app.logger?.severe('Failed to create server', error);
throw ArgumentError('[Driver]Failed to create server');
});
}
@ -164,7 +163,7 @@ abstract class Driver<
..registerSingleton<ParseResult<RouteResult>?>(tuple.item3)
..registerSingleton<ParseResult?>(tuple.item3);
if (app.environment.isProduction && app.logger != null) {
if (!app.environment.isProduction && app.logger != null) {
req.container?.registerSingleton<Stopwatch>(Stopwatch()..start());
}
@ -250,7 +249,7 @@ abstract class Driver<
// Ideally, we won't be in a position where an absolutely fatal error occurs,
// but if so, we'll need to log it.
if (app.logger != null) {
app.logger?.severe(
app.logger!.severe(
'Fatal error occurred when processing $uri.', e, trace);
} else {
stderr
@ -323,7 +322,7 @@ abstract class Driver<
ResponseContext res,
{bool ignoreFinalizers = false}) {
Future<void> _cleanup(_) {
if (app.environment.isProduction &&
if (!app.environment.isProduction &&
app.logger != null &&
req.container!.has<Stopwatch>()) {
var sw = req.container!.make<Stopwatch>();
@ -334,11 +333,10 @@ abstract class Driver<
}
if (!res.isBuffered) {
if (res.isOpen) {
//if (res.isOpen) {
return res.close().then(_cleanup);
}
return Future.value();
//}
//return Future.value();
}
var finalizers = ignoreFinalizers == true

View file

@ -1,5 +1,5 @@
name: angel3_framework
version: 4.2.3
version: 4.2.4
description: A high-powered HTTP server extensible framework with dependency injection, routing and much more.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/framework
@ -35,3 +35,6 @@ dev_dependencies:
io: ^1.0.0
test: ^1.17.5
lints: ^1.0.0
dependency_overrides:
angel3_container:
path: ../container/angel_container

View file

@ -22,7 +22,7 @@ Future<void> plaintext(var message) async {
var url = Uri.http('localhost:3000', '/plaintext');
var response = await http.get(url);
if (response.statusCode == 200) {
print('Execution($message): success');
print('Execution($message): ${response.body}.');
} else {
print('Execution($message): error');
}
@ -92,10 +92,10 @@ Future<void> dbMultipleQuery(var message) async {
}
void main() async {
var concurrency = 100;
var concurrency = 6000;
for (var i = 0; i < concurrency; i++) {
Isolate.spawn(dbUpdate, 'Instance_$i');
Isolate.spawn(plaintext, 'Instance_$i');
}
await Future.delayed(const Duration(seconds: 10));