0

Any Android App produces Logs in the LogCat, even those not generated by developer's source code via Log.d, Log.i, Log.w and Log.e etc. etc. etc.. Perhaps Google Developers has some "automagic" thing for this, I don't know about that...

The point is I remember, years ago, I could somehow extend the class Application, override one or several of it's methods, and then:

  • Add my own code to process any single Log object generated by my App in the LogCat
  • Do whatever I wanted with them (getting the label and the description strings, and then send them via mail, Slack etc., basically)
  • And then, calling super on that method and let the system do with that Log whatever Application by default does with it...

or something like that... if I recall correctly, I could do this with any log in my app's namespace. Or maybe it was just the crash handler? I can't remember...

It's been so long since I accomplished that (several years already!), so I don't remember how could I do that anymore... I search the internet like crazy trying to recall, but I am struggling to find it again... :-S

// ...public?? oO
[¿¿??] class MyApp extends Application [...] {
// [...]

    @Override
    public void whateverMethodItWasIDontRemember(params) {
        // My coding stuff for the error reports
        /* magic :D */
        sendTheLogsMyWay();

        // I bet this is important
        super.whateverMethodItWasIDontRemember(params);
    }

    // [...]
}

I am about to launch the first Beta version of a new app, so I want beta testers to have a reliable way to send me LogCat's feed if anything has to be reported due to crashes, unexpected behaviour etc.


I mean, it would be ridiculous having to fill with CustomLogs every inch of source code for the beta version, when, in most cases, default logs are more than enough to see why it crashed (errors), or what optimization problems (usually warnings) might the Beta Tester have... not to mention that, if I forget to monitor something this way, the ridiculously big effort to log every single line of my code would be useless... oO

// -__- Mmm... perhaps extending Log itself
//        would be more elegant... 
import android.util.Log

public final class CustomLog {
    public static void d(String label, String msg) {
        // AKA My code to handle it
        packItForNextErrorReport(label, msg);

        Log.d(label, msg);
    }

    /*
      * ... and so on with Log.i, w and e.
      *    ...I think you get the idea
      */
}
SebasSBM
  • 860
  • 2
  • 8
  • 32
  • Perhaps you were thinking of [ACRA](https://github.com/ACRA/acra) documentation [here](https://www.acra.ch/docs/Setup) – Morrison Chang Apr 13 '22 at 01:46
  • I am not sure... perhaps, but I don't remember using other libraries than the ones for HTTP calls, or mail sendings or things like that... perhaps I don't remember some library I needed, perhaps I didn't need more than extending `Application` and override some method... but I did make it work via Slack, that's for sure – SebasSBM Apr 13 '22 at 02:10

0 Answers0