Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logs parsing error #277

Closed
Petitoto opened this issue Feb 8, 2024 · 0 comments · Fixed by #353
Closed

Logs parsing error #277

Petitoto opened this issue Feb 8, 2024 · 0 comments · Fixed by #353
Labels
bug core This PR change the core

Comments

@Petitoto
Copy link
Member

Petitoto commented Feb 8, 2024

Logs parsing in log file may introduce errors when the error message includes ;, - or :.

This issue is introduced by the way how Titan stores logs and parses them:

Logs saving:

bool writeLog(Log log) {
try {
logFile.writeAsStringSync(log.toString(), mode: FileMode.append);
return true;

String toString() {
return "${time.toIso8601String()} - ${level.toString().split(".").last.toUpperCase()}: $message;";
}

Logs parsing:

List<Log> getLogs() {
return logFile
.readAsStringSync()
.split(";")
.reversed
.toList()
.sublist(1)
.map((e) {
final split = e.split(" - ");
if (split.length < 2) {
return Log.empty().copyWith(message: e);
}
String message = split[1].split(": ").last;
String level = split[1].split(": ").first;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug core This PR change the core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants