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

FileOutput can't be imported in console app #51

Closed agordeev closed 4 years ago

haarts commented 4 years ago

I'm not sure what is happening. Can you include some console output, or some other indication of what exactly is not working?

agordeev commented 4 years ago

Sorry, my bad. I'm unable to import FileOutput in my console Dart app. It's just not visible to me. Seems like it's not exported properly.

haarts commented 4 years ago

That doesn't sound right. Could you provide me with some minimal example showing the behaviour? Or some code snippets? Thanks!

agordeev commented 4 years ago
Screenshot 2020-07-04 at 09 52 52

Simply try to import FileOutput into your console app. That won't work. Seems like the reason is in this line of logger.dart:

export 'src/log_output.dart'
    if (dart.library.io) 'src/outputs/file_output.dart';
haarts commented 4 years ago

I've looked into the issue and it is weird. I believe this has something to do with the Dart LSP server. The code as you wrote it works (but crashes because you didn't pass a File instance). Only the IDE is confused. I'm sure it has something to do with the conditional import but this seems a rabbit hole I'm unwilling to touch ATM.

The correct call would be final fileLogger = Logger(output: FileOutput(file: File('/tmp/sheep.log')));.

Lemme know if this works.

ghenry commented 4 years ago

Hi all,

FileOutput is not found for me. This shows red, but Logger is fine. Weird:

var logger = Logger(output: FileOutput(()));

Thanks.

IanWorthington commented 3 years ago

I encountered this problem yesterday. Reading around it seems to require a -D constant being set to activate the import. It's unclear to me if this works in Dart 2.0. I worked around the problem by importing the implementation file and living with the subsequent warning.

rubenvereecken commented 3 years ago

Same issue here, we ended up rolling with our own implementation which isn't great.

jpsarda commented 2 years ago

Same problem.

[edit] solved it with import 'package:logger/src/outputs/file_output.dart';