I’m trying to create a pass through logging container for uart on the rpi3. i.e. we have an mcu that is printing out over uart, and I’m wanting to watch that output through connecting the uart lines of an rpi3 to the mcu and printing the uart out to stdout through pyserial.
In going through this, I realized that if you print things too quickly data seems to be lost in the logs. What is the best process for getting around this?
Example code:
from datetime import datetime
for i in range(5000):
print("UTC "+ str(datetime.now()) + " : " + str(i) )
Expected output ( aka what I see on my local laptop )
UTC 2023-04-08 01:13:34.726017 : 0
UTC 2023-04-08 01:13:34.726069 : 1
UTC 2023-04-08 01:13:34.726075 : 2
UTC 2023-04-08 01:13:34.726079 : 3
UTC 2023-04-08 01:13:34.726082 : 4
UTC 2023-04-08 01:13:34.726086 : 5
UTC 2023-04-08 01:13:34.726089 : 6
UTC 2023-04-08 01:13:34.726093 : 7
UTC 2023-04-08 01:13:34.726096 : 8
UTC 2023-04-08 01:13:34.726100 : 9
UTC 2023-04-08 01:13:34.726103 : 10
UTC 2023-04-08 01:13:34.726106 : 11
UTC 2023-04-08 01:13:34.726110 : 12
UTC 2023-04-08 01:13:34.726113 : 13
UTC 2023-04-08 01:13:34.726116 : 14
UTC 2023-04-08 01:13:34.726120 : 15
UTC 2023-04-08 01:13:34.726123 : 16
UTC 2023-04-08 01:13:34.726126 : 17
UTC 2023-04-08 01:13:34.726130 : 18
UTC 2023-04-08 01:13:34.726133 : 19
UTC 2023-04-08 01:13:34.726136 : 20
UTC 2023-04-08 01:13:34.726140 : 21
UTC 2023-04-08 01:13:34.726143 : 22
UTC 2023-04-08 01:13:34.726146 : 23
UTC 2023-04-08 01:13:34.726149 : 24
UTC 2023-04-08 01:13:34.726153 : 25
UTC 2023-04-08 01:13:34.726156 : 26
UTC 2023-04-08 01:13:34.726159 : 27
UTC 2023-04-08 01:13:34.726176 : 28
UTC 2023-04-08 01:13:34.726179 : 29
UTC 2023-04-08 01:13:34.726182 : 30
UTC 2023-04-08 01:13:34.726185 : 31
UTC 2023-04-08 01:13:34.726188 : 32
UTC 2023-04-08 01:13:34.726192 : 33
UTC 2023-04-08 01:13:34.726195 : 34
UTC 2023-04-08 01:13:34.726198 : 35
UTC 2023-04-08 01:13:34.726201 : 36
UTC 2023-04-08 01:13:34.726204 : 37
UTC 2023-04-08 01:13:34.726208 : 38
UTC 2023-04-08 01:13:34.726211 : 39
UTC 2023-04-08 01:13:34.726214 : 40
UTC 2023-04-08 01:13:34.726217 : 41
UTC 2023-04-08 01:13:34.726220 : 42
UTC 2023-04-08 01:13:34.726224 : 43
UTC 2023-04-08 01:13:34.726227 : 44
UTC 2023-04-08 01:13:34.726230 : 45
UTC 2023-04-08 01:13:34.726233 : 46
UTC 2023-04-08 01:13:34.726236 : 47
UTC 2023-04-08 01:13:34.726240 : 48
UTC 2023-04-08 01:13:34.726243 : 49
UTC 2023-04-08 01:13:34.726246 : 50
[ this goes all the way smoothly to 5000 ]
output from balena logs
As you can see, hardly any of the logs were registered. I’m perfectly fine with slower latency or going into a terminal or something to see the real output - especially since we’ll need logs that last for weeks at a time.
What’s the balena way of tackling this?