Merge pull request #78 from dukefirehawk/feature/perf-1

Reduced debugging verbosity
This commit is contained in:
Thomas Hii 2022-08-31 21:35:11 +08:00 committed by GitHub
commit 272363052b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 30 deletions

View file

@ -1,5 +1,9 @@
# Change Log
## 7.0.1
* Reduced debugging verbosity
## 7.0.0
* Require Dart >= 2.17

View file

@ -45,9 +45,9 @@ class MariaDbExecutor extends QueryExecutor {
}
}
logger.warning('Query: $query');
logger.warning('Values: $params');
logger.warning('Returning Query: $returningQuery');
//logger.warning('Query: $query');
//logger.warning('Values: $params');
//logger.warning('Returning Query: $returningQuery');
if (returningQuery.isNotEmpty) {
// Handle insert, update and delete
@ -77,17 +77,14 @@ class MariaDbExecutor extends QueryExecutor {
@override
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
T? returnValue = await _connection.transaction((ctx) async {
// TODO: To be relooked at
try {
logger.fine('Entering transaction');
//logger.fine('Entering transaction');
//var tx = MariaDbExecutor(conn, logger: logger);
_transactionContext = ctx;
return await f(this);
} catch (e) {
logger.severe('Failed to run transaction', e);
rethrow;
} finally {
logger.fine('Exiting transaction');
}
});

View file

@ -88,8 +88,8 @@ class MySqlExecutor extends QueryExecutor {
var value = substitutionValues[name];
if (value is DateTime && value.isUtc) {
var t = value.toLocal();
logger.warning('Datetime deteted: $name');
logger.warning('Datetime: UTC -> $value, Local -> $t');
//logger.warning('Datetime deteted: $name');
//logger.warning('Datetime: UTC -> $value, Local -> $t');
substitutionValues[name] = t;
}
@ -98,9 +98,9 @@ class MySqlExecutor extends QueryExecutor {
//var params = substitutionValues.values.toList();
//var params = [];
logger.warning('Query: $query');
logger.warning('Values: $substitutionValues');
//logger?.warning('Returning Query: $returningQuery');
//logger.warning('Query: $query');
//logger.warning('Values: $substitutionValues');
//logger.warning('Returning Query: $returningQuery');
if (returningQuery.isNotEmpty) {
// Handle insert, update and delete
@ -108,10 +108,10 @@ class MySqlExecutor extends QueryExecutor {
if (query.startsWith("INSERT")) {
var result = await _connection.execute(query, substitutionValues);
logger.warning(result.lastInsertID);
//logger.fine(result.lastInsertID);
query = returningQuery;
//logger?.warning('Result.insertId: ${result.insertId}');
//logger.fine('Result.insertId: ${result.insertId}');
// Has primary key
if (returningQuery.endsWith('.id=?')) {
query = query.replaceAll("?", ":id");
@ -126,15 +126,15 @@ class MySqlExecutor extends QueryExecutor {
}
}
logger.warning('Query 2: $query');
logger.warning('Values 2: $substitutionValues');
//logger.warning('Query 2: $query');
//logger.warning('Values 2: $substitutionValues');
// Handle select
return _connection.execute(query, substitutionValues).then((results) {
var tmpData = results.rows;
for (var element in tmpData) {
logger.warning("[Result] : ${element.assoc()}");
}
// var tmpData = results.rows;
//for (var element in tmpData) {
// logger.warning("[Result] : ${element.assoc()}");
//}
return results.rows.map((r) => r.typedAssoc().values.toList()).toList();
});
@ -153,18 +153,16 @@ class MySqlExecutor extends QueryExecutor {
@override
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
logger.warning("Transaction");
//logger.warning("Transaction");
T? returnValue = await _connection.transactional((ctx) async {
try {
logger.fine('Entering transaction');
//logger.fine('Entering transaction');
var tx = MySqlExecutor(ctx, logger: logger);
return await f(tx);
} catch (e) {
logger.severe('Failed to run transaction', e);
rethrow;
} finally {
logger.fine('Exiting transaction');
}
});

View file

@ -1,5 +1,5 @@
name: angel3_orm_mysql
version: 7.0.0
version: 7.0.1
description: MySQL support for Angel3 ORM. Includes functionality for querying and transactions.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_mysql

View file

@ -1,5 +1,9 @@
# Change Log
## 7.0.1
* Reduced debugging verbosity
## 7.0.0
* Require Dart >= 2.17

View file

@ -107,7 +107,7 @@ class PostgreSqlExecutor extends QueryExecutor {
var txResult = await conn.transaction((ctx) async {
try {
logger.fine('Entering transaction');
//logger.fine('Entering transaction');
var tx = PostgreSqlExecutor(ctx, logger: logger);
returnValue = await f(tx);
@ -115,8 +115,6 @@ class PostgreSqlExecutor extends QueryExecutor {
} catch (e) {
ctx.cancelTransaction(reason: e.toString());
rethrow;
} finally {
logger.fine('Exiting transaction');
}
});
@ -176,7 +174,7 @@ class PostgreSqlExecutorPool extends QueryExecutor {
Future _open() async {
if (_connections.isEmpty) {
_connections.addAll(await Future.wait(List.generate(size, (_) async {
logger.fine('Spawning connections...');
//logger.fine('Spawning connections...');
var conn = connectionFactory();
await conn.open();
//return conn

View file

@ -1,5 +1,5 @@
name: angel3_orm_postgres
version: 7.0.0
version: 7.0.1
description: PostgreSQL support for Angel3 ORM. Includes functionality for querying and transactions.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_postgres