mxk / go-imap

IMAP4rev1 Client for Go
BSD 3-Clause "New" or "Revised" License
212 stars 63 forks source link

Debugging idea: log progress of a data transfer #20

Open andlabs opened 8 years ago

andlabs commented 8 years ago

It would be useful for debugging to have the built-in debug log display the progress of a data literal send over time, assuming this is even possible. Perhaps only in an imap.Wait() call?

Example, when doing a UID FETCH something BODY[] with imap.LogAll enabled, instead of:

[imap] 13:20:20 S:  BODY[] {2120811}
[imap] 13:20:20 S: literal 111 bytes
[imap] 13:20:37 S: literal 2048 bytes
[imap] 13:21:34 S: literal 2048 bytes
[imap] 13:21:34 S: literal 2048 bytes
[imap] 13:21:34 S: literal 496 bytes
[imap] 13:21:34 S: literal 2048 bytes
[imap] 13:21:34 S: literal 2048 bytes

it would say something like

[imap] 13:20:20 S:  BODY[] {2120811}
[imap] 13:20:20 S: literal 111 bytes (111/2120811 bytes received)
[imap] 13:20:37 S: literal 2048 bytes (2159/2120811 bytes received)
[imap] 13:21:34 S: literal 2048 bytes (4207/2120811 bytes received)
[imap] 13:21:34 S: literal 2048 bytes (6255/2120811 bytes received)
[imap] 13:21:34 S: literal 496 bytes (6751/2120811 bytes received)
[imap] 13:21:34 S: literal 2048 bytes (8799/2120811 bytes received)
[imap] 13:21:34 S: literal 2048 bytes (10847/2120811 bytes received)

Is this possible? I'm not familiar enough with either IMAP or the package's source to tell myself. Thanks!