max log message length to store in db

This commit is contained in:
julian 2023-01-16 08:34:52 -06:00
parent 09b51def04
commit 3d4d57a97c

View file

@ -49,9 +49,16 @@ class Logging {
Logger.print(object, normalLength: !printFullLength); Logger.print(object, normalLength: !printFullLength);
return; return;
} }
String message = object.toString();
// random value to check max size of message before storing in db
if (message.length > 20000) {
message = "${message.substring(0, 20000)}...";
}
final now = core.DateTime.now().toUtc(); final now = core.DateTime.now().toUtc();
final log = Log() final log = Log()
..message = object.toString() ..message = message
..logLevel = level ..logLevel = level
..timestampInMillisUTC = now.millisecondsSinceEpoch; ..timestampInMillisUTC = now.millisecondsSinceEpoch;
if (level == LogLevel.Error || level == LogLevel.Fatal) { if (level == LogLevel.Error || level == LogLevel.Fatal) {