Reputation: 127
I wanted to print a log statement onto any LogCat console (Verbose, Debug, etc) but I can't seem to find a way to do it.
The print()
or debugPrint()
doesn't seem to work, or better yet should I say I don't know where they are printing.
Also, for some reason, the LogCat console is saying "No connected devices" and "No debuggable process" even though I have the emulator running in background and the files are executing on the emulator perfectly.
Upvotes: 4
Views: 11378
Reputation: 1202
Based on Flutter Doc, the logging view displays events from the Dart runtime, application frameworks (like Flutter), and application-level logging events.By default, the logging view shows:
stdout
and stderr
from applicationsRefer the Debugging Flutter Applications Programmatically Doc. You can use:
stderr.writeln('print me');
Or
import 'dart:developer' as developer;
void main() {
developer.log('log me', name: 'my.app.category');
developer.log('log me 1', name: 'my.other.category');
developer.log('log me 2', name: 'my.other.category');
}
Or
import 'dart:convert';
import 'dart:developer' as developer;
void main() {
var myCustomObject = ...;
developer.log(
'log me',
name: 'my.app.category',
error: jsonEncode(myCustomObject),
);
}
to log from your app.
Upvotes: 8