A simple append-only logger canister

If you are looking for a simple, ready-to-use logger solution, you can try this out:

You can either use it as a Motoko module, or use the example text based logger actor to deploy your own logger canister. It offers a single append method to keep track of logs. Logs are put into buckets, and new buckets will be created when old ones become full.

The only other notable administrative method is removing the oldest buckets. All logs are indexed by a line number and can be downloaded to local for offline analysis. Removing buckets does not affect the index.

It can be extended to support “block-chained” logs, i.e. log entries that keep a hash of their parent log entry, which then can be used to prove its immutable history has not been tampered with. But I’ve no use of such functionality, so I don’t see myself implementing it any time soon.

Anyway, just a little tool that can be handy to keep track of events. I’m using it in my other project Canister Tip Jar.

8 Likes

I there a similar solution in Rust?
I would be so grateful if there’s already a solution in Rust instead of trying to implement it myself.

There is an example in the repo that deploys a standalone canister. Then you can just call it from your rust canister. Works 100%.

Thanks I will give it a try