simc / logger

Small, easy to use and extensible logger which prints beautiful logs.
https://pub.dev/packages/logger
MIT License
1.07k stars 129 forks source link

It is not logging error and stack trace #98

Open kristijorgji opened 3 years ago

kristijorgji commented 3 years ago

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 ?

bsr203 commented 3 years ago

same issue. No stack trace printed though passed.

nishanttyagi18 commented 2 years ago

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