majoson-chen/micropython-ulogger

Transferring logs over network

peedrr opened this issue · 1 comments

Hey @whales-chen, thank you for this library! It looks really interesting and I really appreciate all of the documentation you have put together, especially the tips on optimising for low power devices. It's really helpful. 🙇🏻

I am looking at ways to transfer logs across the network (in my case, into Kubernetes). My microcontrollers are on battery power and use deepsleep. They connect to network when they wake up to receive updates/instructions. I am thinking to add a new direction=TO_NETWORK and to use a fallback strategy like this:

  1. Device wakes up
  2. Device checks if network is reachable
  3. Depending if network is reachable or not:
    (If network is reachable:)
    3.1. Check if there are existing (undelivered) logs on the filesystem
    3.2. Deliver the existing logs and wait for acknowledgement
    3.3. Delete logs from the filesystem
    3.4. Write any new log entries directly to network (if still available)
    (If network is unreachable:)
    3.1. Write any new logs to file
  4. Device goes back to sleep

Before I start implementing this I wanted to ask for your thoughts on the strategy in general and also ask if you would be happy to receive a PR which implements the direction=TO_NETWORK. Initially I will be supporting MQTT, however I am looking at implementing NATS and, of course, the library should be able to handle other messaging protocols as well.

Thanks again for your work on this 🤜🏻✨🤛🏻

thanks for your suggestion, and i will appreciate if i can receive your pull request.
But I think we'd better draw up a more detailed draft that clarifies the form of the API interface, and provide some code snippets to illustrate how the new functionality works. If you are interested, please fork out a new branch to develop