logger
logger copied to clipboard
error: The method 'FileOutput' isn't defined
Hi all,
As per https://github.com/leisim/logger/issues/51#issuecomment-653730601
How can I get Android Studio to find this as Dart Analysis is failing in our Actions. It's obviously to do with https://github.com/leisim/logger/blob/cf216e03d111b524c220db75c5e243fec8c8a081/lib/logger.dart#L21 but I'm not sure how to let them know.
Thanks, Gavin.
I am having the same problem. For development purposes I want logging both to file and console so I use MultiOutput with ConsoleOutput and FileOutput.
However dart is not able to see FileOutput class. For now I hacked around it by excluding the file i n analysis_options.yml but obviously that's not a good solution at all since I can introduce other bugs.
If this is a platform problem, perhaps for web it'd make sense to expose FileOutput as well which does nothing (or throws) or even use experimental File API.
Any suggestions would be appreciated. I have also tried using // ignore comments but those are for linting only and not for errors.
I'm not sure if I understood your problem correctly but I think I had a similar problem and what 'fixed' it for me was
import 'package:logger/src/outputs/file_output.dart';
With that line Android Studio is able to see the class and you can go to it.
But code e.g. like this
var logger = Logger(
printer: PrettyPrinter(),
output: FileOutput(
file: File("out.log"),
),
);
works without the import already, so it's really weird AS is not able to analyze it without the import. It even warns: "Don't import implementation files from another package." so thats still not the best way.
Yeah that works thanks for pointing that out. I skip the warning via ignore comment for now.
Can not find FileOutput too.

In logger plugin source code:

Don't import file_output.dart:

@leisim Can you help us?
I think the solution here is to create abstract class FileOutput and export it anyway.
But inside the file use conditional import. Then if program is running on web use dummy implementation and real implementation otherwise.
What's the latest news on this?