logger icon indicating copy to clipboard operation
logger copied to clipboard

It is not logging error and stack trace

Open kristijorgji opened this issue 4 years ago • 2 comments

Version 1.0.0

Usage: In development mode catching all flutter logs and printing them

onError: config.isProduction
          ? FirebaseCrashlytics.instance.recordError
          : _reportCrash);

void _reportCrash(dynamic error, StackTrace stackTrace) {
  getLogger('app_runner_reportCrash').e(error.toString(), [error, stackTrace]);
}

Problem: It is not printing the stack trace, just the message of error:

flutter: \^[[38;5;196m⛔  app_runner_reportCrash - ValueStream has no value. You should check ValueStream.hasValue before accessing ValueStream.value, or use ValueStream.valueOrNull instead.
<…>

Maybe is trimming the rest ??? I see <…> in output as text but would be great to have at least x top lines of stack trace.

I can modify the call to :

  getLogger('app_runner_reportCrash').e(stackTrace.toString(), [error, stackTrace]);

Then I can see the stack trace but seems hacky, why is the library then accepting stack trace as second arg in the array ?

kristijorgji avatar Jun 22 '21 17:06 kristijorgji

same issue. No stack trace printed though passed.

bsr203 avatar Sep 23 '21 17:09 bsr203

Did anyone find any solution for printing stack traces? I am using the below custom printer but the stack trace is printing null.

@override
  List<String> log(LogEvent event) {
    final color = PrettyPrinter.levelColors[event.level];
    final emoji = PrettyPrinter.levelEmojis[event.level];
    final message = event.message;
    final stackTrace = event.stackTrace;

    return [color!('$emoji $className: $message : $stackTrace')];
  }

Output

image

nishanttyagi18 avatar Jun 11 '22 10:06 nishanttyagi18