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

Support multiple printers #71

Closed
chimon2000 opened this issue May 1, 2023 · 1 comment
Closed

Support multiple printers #71

chimon2000 opened this issue May 1, 2023 · 1 comment

Comments

@chimon2000
Copy link

It would be nice to be able to log using multiple printers, for instance if I want to use the flutter printer to log to dart devtools, but also use the pretty printer to log in the terminal.

@lukaknezic
Copy link
Contributor

Hey @chimon2000. You can extend LoggyPrinter to make your own printer for logging in any way you would want/need to. Here is simple example of custom multiple printer:

class MultiPrinter extends LoggyPrinter{
  MultiPrinter({
    required this.consolePrinter,
    required this.cloudPrinter,
    required this.filePrinter,
});

  final LoggyPrinter consolePrinter;
  final LoggyPrinter cloudPrinter;
  final LoggyPrinter filePrinter;

  @override
  void onLog(LogRecord record){
    consolePrinter.onLog(record);
    filePrinter.onLog(record);
    
    // Log to cloud only if app is run in release mode
    if(kReleaseMode) {
      cloudPrinter.onLog(record);
    }
  }
}

@zenled zenled closed this as completed Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants