I’m pretty sure about this, but I wanted to get extra verification. In order for juju-log
to work it needs a JUJU_CONTEXT_ID
right?
Lucky charms have a daemon that stays running for the time that the charm is installed. I have the daemon using juju-log
for its logging, but it seems that the logs stop coming through to the juju debug-log
after the first install
hook runs. I realized that this is probably because the daemon continues to have the same JUJU_CONTEXT_ID
that it recieved from the install
hook when other hooks are run.
I doubt it, but is there anyway to have something log to the Juju log outside of a charm context so that the logs will come through regardless of whether a charm hook is currently running? I suppose I could use juju run 'juju-log "mesage"'
maybe. Would using juju run
for every log message be inefficient because it has to create a new context every time?
If I have to, I can make sure to update the logging context every time a charm hook is run, but then if anything happens in the Lucky daemon while a charm hook isn’t running, the user would not see those logs, which would be confusing and ineffective.
Normally, nothing happens in a charm without a charm hook running, but feature I have considered adding to Lucky was the ability to run “cron” scripts or other asynchronous scripts which would result in scripts being run outside of the Juju hooks.
Edit:
I just realized, maybe I can create a Juju context specifically for the Lucky daemon by doing juju run 'lucky daemon start --foreground'
. Then that context should exist until the daemon process exits.