Centralize Flutter logs using log.jod.li

In order to centralize Flutter logs using log.jod.li , one needs to:

  1. Create an account for free on https://en.log.jod.li
  2. Add the following to pubspec.yaml under dependencies:

    http: ^0.12.0+2

  3. Click on “Packages get” of run this command at the project root folder:

    flutter packages get

  4. Import the following:

    import 'package:http/http.dart' as http;
    import 'dart:io';


  5. Add this function:

    Future jilog (String message,{bool encoded=false})async {
    try {
    String m="";
    String remaining="";
    if(!encoded){
    m=Uri.encodeFull(message);
    }
    else{
    m=message;
    }
    if(m.length>1700){
    remaining=m.substring(1700);
    m=m.substring(0,1700);
    }
    final response = await http.get('https://en.log.jod.li/?api=a&u=myUserName&k=my16CharsLongKey&c=myGUID&a=myApp&m=${m}');
    if(remaining.length>0){
    jilog(remaining, encoded:true);
    }
    }
    catch(e){
    print("Error: Failed to send logs: ${e.toString()}");
    }
    }

  6. Replace in the function the following elements of the URL:

    myUserName: user name received in the email at free user registration on log.jod.li .

    my16CharsLongKey: 16 characters long key received in the email at free user registration on log.jod.li .

    myGUID: arbitrary string that is meant for you to identify the user anonymously. You can also leave it as it is.

    myApp: arbitrary string that is meant for you to identify the application sending the logs. You can also leave it as it is.

    Note that this URL is prebuilt in the log.jod.li free registration email.

  7. Call the function to add logs:

    jilog("Yes, this got executed!");

  8. Check your logs from the log.jod.li page (link in the registration email or enter your user and key on the page).

The logs will flow on the page as they are sent by your Flutter code.

Logs as displayed on log.jod.li when sent from a Flutter application.

Leave a Reply

Your email address will not be published. Required fields are marked *