diff --git a/lib/core/notes_folder_fs.dart b/lib/core/notes_folder_fs.dart index 2b22cc7c..bfedb8ce 100644 --- a/lib/core/notes_folder_fs.dart +++ b/lib/core/notes_folder_fs.dart @@ -186,12 +186,15 @@ class NotesFolderFS with NotesFolderNotifier implements NotesFolder { } if (fsEntity is Directory) { - Log.v("Found directory ${fsEntity.path}"); var subFolder = NotesFolderFS(this, fsEntity.path); if (subFolder.name.startsWith('.')) { + Log.v("Ignoring Folder", props: { + "path": fsEntity.path, + "reason": "Hidden folder", + }); continue; } - Log.v("Found folder ${fsEntity.path}"); + Log.v("Found Folder", props: {"path": fsEntity.path}); _addFolderListeners(subFolder); _folders.add(subFolder); @@ -203,11 +206,21 @@ class NotesFolderFS with NotesFolderNotifier implements NotesFolder { } var note = Note(this, fsEntity.path); - if (!note.filePath.toLowerCase().endsWith('.md')) { - Log.v("Ignoring file ${fsEntity.path}"); + if (note.fileName.startsWith('.')) { + Log.v("Ignoring file", props: { + "path": fsEntity.path, + "reason": "Starts with a .", + }); continue; } - Log.v("Found file ${fsEntity.path}"); + if (!note.filePath.toLowerCase().endsWith('.md')) { + Log.v("Ignoring file", props: { + "path": fsEntity.path, + "reason": "Doesn't end with a .md", + }); + continue; + } + Log.v("Found file", props: {"path": fsEntity.path}); _addNoteListeners(note); _notes.add(note); diff --git a/lib/screens/debug_screen.dart b/lib/screens/debug_screen.dart index b2b3a233..40f0f191 100644 --- a/lib/screens/debug_screen.dart +++ b/lib/screens/debug_screen.dart @@ -79,12 +79,33 @@ class _DebugScreenState extends State { if (msg.stack != null) { str += ' ' + msg.stack; } + + var props = []; + msg.props?.forEach((key, value) { + var emptySpace = TextSpan( + text: '\n ', + style: textStyle.copyWith(fontWeight: FontWeight.bold)); + props.add(emptySpace); + + var keySpan = TextSpan( + text: '$key: ', + style: textStyle.copyWith( + fontWeight: FontWeight.bold, + ), + ); + var valueSpan = TextSpan(text: value.toString()); + + props.add(keySpan); + props.add(valueSpan); + }); + return RichText( text: TextSpan(children: [ TextSpan( text: timeStr, style: textStyle.copyWith(fontWeight: FontWeight.bold)), TextSpan(text: str), + ...props, ], style: textStyle), ); } diff --git a/lib/utils/logger.dart b/lib/utils/logger.dart index 9325851f..28e7443f 100644 --- a/lib/utils/logger.dart +++ b/lib/utils/logger.dart @@ -29,29 +29,34 @@ class Log { await setLogCapture(true); } - static void v(String msg, {dynamic ex, StackTrace stacktrace}) { + static void v(String msg, + {dynamic ex, StackTrace stacktrace, Map props}) { Fimber.v(msg, ex: ex, stacktrace: stacktrace); - _write('v', msg, ex, stacktrace); + _write('v', msg, ex, stacktrace, props); } - static void d(String msg, {dynamic ex, StackTrace stacktrace}) { + static void d(String msg, + {dynamic ex, StackTrace stacktrace, Map props}) { Fimber.d(msg, ex: ex, stacktrace: stacktrace); - _write('d', msg, ex, stacktrace); + _write('d', msg, ex, stacktrace, props); } - static void i(String msg, {dynamic ex, StackTrace stacktrace}) { + static void i(String msg, + {dynamic ex, StackTrace stacktrace, Map props}) { Fimber.i(msg, ex: ex, stacktrace: stacktrace); - _write('i', msg, ex, stacktrace); + _write('i', msg, ex, stacktrace, props); } - static void e(String msg, {dynamic ex, StackTrace stacktrace}) { + static void e(String msg, + {dynamic ex, StackTrace stacktrace, Map props}) { Fimber.e(msg, ex: ex, stacktrace: stacktrace); - _write('e', msg, ex, stacktrace); + _write('e', msg, ex, stacktrace, props); } - static void w(String msg, {dynamic ex, StackTrace stacktrace}) { + static void w(String msg, + {dynamic ex, StackTrace stacktrace, Map props}) { Fimber.w(msg, ex: ex, stacktrace: stacktrace); - _write('w', msg, ex, stacktrace); + _write('w', msg, ex, stacktrace, props); } static void _write( @@ -59,6 +64,7 @@ class Log { String msg, dynamic ex, StackTrace stackTrace, + Map props, ) { if (logFile == null) { return; @@ -72,6 +78,7 @@ class Log { stack: stackTrace != null ? stackTrace.toString().replaceAll('\n', ' ') : null, + props: props, ); var str = json.encode(logMsg.toMap()); @@ -118,6 +125,7 @@ class LogMessage { String msg; String ex; String stack; + Map props; LogMessage({ @required this.t, @@ -125,6 +133,7 @@ class LogMessage { @required this.msg, this.ex, this.stack, + this.props, }); Map toMap() { @@ -134,6 +143,7 @@ class LogMessage { 'msg': msg, if (ex != null && ex.isNotEmpty) 'ex': ex, if (stack != null && stack.isNotEmpty) 'stack': stack, + if (props != null && props.isNotEmpty) 'p': props, }; } @@ -143,5 +153,6 @@ class LogMessage { msg = map['msg']; ex = map['ex']; stack = map['stack']; + props = map['p']; } }