Issue
I am working on QoE analysis of youtube by finding different states(state buffering, state playing etc..) using ADB commands. The following command shows the status of the youtube video playback.
adb shell dumpsys media_session | grep "state=PlaybackState"
But the problem with above command is it gives output log without timestamp. But I need timestamp for data analysis. Then I found a solution to print time along with state status.
printf '[%s] %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$line";
Combination of both commands result output like this:
state=PlaybackState {state=7, position=-1, buffered position=0, speed=1.0, updated=533687, actions=0, custom actions=[], active item id=-1, error=Bluetooth audio disconnected}
state=PlaybackState {state=0, position=0, buffered position=0, speed=1.0, updated=1243174, actions=8192, custom actions=[], active item id=-1, error=null}
[2021-06-24 15:38:48]
But my requirment is to print the time along with milliseconds(15:38:48.078 like that). How can I do it?
Solution
According to date man-page, you need to use %N
formatter to get nanoseconds.
Since you need milliseconds, you could round the nanoseconds with %3N
.
Final printf command should be:
printf '[%s] %s\n' "$(date '+"%Y-%m-%d %T.%3N"')" "$line";
Answered By - Jay
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.