doublep / logview

Emacs mode for viewing log files
GNU General Public License v3.0
153 stars 18 forks source link

Support Android's Logcat #51

Open thedpws opened 4 months ago

thedpws commented 4 months ago

I propose support for Android's logcat format.

Scope

Details

Android Logcat looks like this example.

...
02-15 08:00:12.370  2009  2009 I MediaCodecsXmlParser: limit: blocks-per-second-range = 1-489600
02-15 08:00:12.370  2009  2009 I MediaCodecsXmlParser: limit: bitrate-range = 1-60000000
02-15 08:00:12.370  2009  2009 I MediaCodecsXmlParser: limit: feature-adaptive-playback = 0
02-15 08:00:12.370  2009  2009 I MediaCodecsXmlParser: limit: max-concurrent-instances = 4
02-15 08:00:12.370  2009  2009 I MediaCodecsXmlParser: limit: performance-point-1920x1080-range = 50-50
02-15 08:00:12.370  2009  2009 I MediaCodecsXmlParser: limit: size-range = 32x32-1920x1080
...

Or more concisely, date time PID TID log-level tag: message

thedpws commented 4 months ago

Hi all! I'd like to implement this. I haven't used logview yet. What roadblocks specific to logcat should I anticipate? Alternatively, is this better implemented by extension rather than directly in the package?

thedpws commented 4 months ago

For my reference, this is an example of a solution by extension.

(use-package logview
    :config
    (add-to-list 'logview-additional-submodes
        '("Android"
            ((format . "TIMESTAMP PID LEVEL: MESSAGE")
             (timestamp . "AndroidTimestamp"))))
    (add-to-list 'logview-additional-level-mappings
        '("Android"
            ((error "E")
             (warning "W")
             (information "I")
             (debug "D")
             (trace "V"))))
    (add-to-list 'logview-additional-timestamp-formats
         '("AndroidTimestamp" (java-pattern . "MM-dd HH:mm:ss.SSS"))))
doublep commented 4 months ago

What roadblocks specific to logcat should I anticipate?

Probably none. Basically, you just need to add appropriate values to logview-std-* variables instead of logview-additional-* to make this standard.

PID

As Logview doesn't support that, I'd suggest using THREAD. It also has a comparable meaning in this case, as each process' messages can be seen as a (mostly) independent stream, which are then all collected into one file.

About timestamp format: is it specified anywhere that timestamps are formatted exactly like this? Can it somehow be dependent on your machine's locale instead?

doublep commented 4 months ago

Also, e.g. this page shows substantially different examples. Can you point me to some specification?

thedpws commented 4 months ago

Hey @doublep , It seems Android supports different formats for the logs. My example can be reproduced with the -v threadtime modifier (which is default). What do you think about supporting the default as the standard?

doublep commented 4 months ago

My example can be reproduced with the -v threadtime modifier (which is default).

Sorry, I have no idea with what that modifier is used, I don't develop anything on Android. Can you provide any link?

What do you think about supporting the default as the standard?

That would be the best, but I haven't yet seen the standard. We could also add support for several common formats, not necessarily just one, but I need to see them somewhere first.