Logging flutter apps to remote using socket. In order to connect to remote app, you need to be in the same local network. The tester will be able to see all the logs inside the client app.
You can find the client app source code here.
Add
flutter_socket_log_plugin : # latest version
or run
flutter pub add flutter_socket_log_plugin
Install client app using the flutter source code for windows, linux, mac, android, ios or install app for windows and android.
void main() {
// add conditions to initialize the plugin
FlutterSocketLogPlugin.init(appName: 'Dummy App');
runApp(const MyApp());
}
FlutterSocketLogPlugin.log(
'Write your logs',
DefaultLogs.debug, // customize logs if you want
[DefaultLogs.network], // add your log tags, customize tags
);
List<LogLevel> logLevels = [
FlutterSocketLogPlugin.createLogLevel(
'Critical',
Colors.cyan.value,
Icons.warning.codePoint,
),
FlutterSocketLogPlugin.createLogLevel(
'Alert',
Colors.red.value,
Icons.error.codePoint,
)
];
List<LogTag> logTags = [
FlutterSocketLogPlugin.createTag(
'Request',
Colors.blue.value,
Icons.network_wifi.codePoint,
),
FlutterSocketLogPlugin.createTag(
'Response',
Colors.green.value,
Icons.network_wifi.codePoint,
),
];
FlutterSocketLogPlugin.init(
appName: 'Customized App',
logLevels: logLevels,
logTags: logTags,
);
FlutterSocketLogPlugin.log(
'Write your logs here',
logLevels[0],
[
logTags[0],
logTags[1],
]
);
Logger.debugNetwork('Write your log here');
Log Tags and Log Levels are customizable which means that you can create your own by custom names, colors as well as icons. As a result you can get those in the client application.