SourceHorizon / logger

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

Support different printer for different output #23

Open mivoligo opened 1 year ago

mivoligo commented 1 year ago

Is it possible to have a different printer for each output specified in MultiOutput()? I can't see a good way to do that.

Bungeefan commented 1 year ago

Unfortunately not. Currently, there is only a one-to-one relationship possible between a logger and it's printer.

mivoligo commented 1 year ago

OK, thanks for the very quick response :+1:

Bungeefan commented 1 year ago

You're welcome! Do you want to keep this issue as a feature request, or should I close it?

mivoligo commented 1 year ago

I think keeping it as a feature request could be fine. Maybe someone else will have similar requirements.

shovelmn12 commented 8 months ago

It's pretty easy to write such class:

class MultiOutput extends LogOutput {
  final List<LogOutput> outputs;

  MultiOutput({required this.outputs});

  @override
  Future<void> destroy() async {
    for (final output in outputs)
      await output.destroy();
  }

  @override
  Future<void> init() async {
    for (final output in outputs)
      await output.init();
  }

  @override
  void output(OutputEvent event) {
      for (final output in outputs)
        output.output(event);
  }
}

Good luck :)