logger icon indicating copy to clipboard operation
logger copied to clipboard

error: The method 'FileOutput' isn't defined

Open ghenry opened this issue 4 years ago • 8 comments
trafficstars

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.

ghenry avatar Apr 18 '21 21:04 ghenry

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.

comatory avatar May 26 '21 14:05 comatory

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.

AnanasPizza avatar Jun 02 '21 14:06 AnanasPizza

Yeah that works thanks for pointing that out. I skip the warning via ignore comment for now.

comatory avatar Jun 02 '21 19:06 comatory

Can not find FileOutput too. image

jack24254029 avatar Sep 07 '21 10:09 jack24254029

In logger plugin source code: image

Don't import file_output.dart: image

YowFung avatar Oct 18 '21 06:10 YowFung

@leisim Can you help us?

jack24254029 avatar Jan 17 '22 06:01 jack24254029

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.

qoob23 avatar Jan 25 '22 13:01 qoob23

What's the latest news on this?

ghenry avatar Nov 06 '22 21:11 ghenry