gjcarneiro / yacron

A modern Cron replacement that is Docker-friendly
MIT License
454 stars 38 forks source link

Feature request: logging reporter #33

Closed Nekmo closed 1 year ago

Nekmo commented 4 years ago

Hi,

I would like to write the successful executions to a file, but I think it would be better to support logging to configure logs. In the Python documentation there is an example in Yaml:

https://docs.python.org/3/howto/logging.html#configuring-logging https://docs.python.org/3/library/logging.config.html#dictionary-schema-details

It is only necessary to configure a handler and a format. Loggers can be dynamically created from jobs.

My proposal:

- name: test-01
  command: |
    echo "hello" 1>&2
    sleep 1
    exit 10
  schedule:
    minute: "*/2"
  captureStderr: true
  onFailure:
    report:
      logging:
        format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
        handler:
          class: logging.StreamHandler
          stream: ext://sys.stdout

Supporting the logging module allows to use many other handlers such as rsyslog.

gjcarneiro commented 4 years ago

Hm.. I haven't decided whether this is a brilliant or terrible idea :)

On one hand, you get access of all the standard python logging options, with file rotation, syslog, etc.

On the other hand, configuration of this is a lot more complicated than it needs to be. The end user shouldn't need to care about logging handlers, or reading the Python documentation.

andreas-wittig commented 1 year ago

Thanks again Gustavo for the commit of #82 !! I think this one #33 is just the same ... and can be set to solved? Greetings from Germany, Andreas.

gjcarneiro commented 1 year ago

Not exactly the same, but there's some overlap, I guess. Anyway, this one is more complicated.
I am going to close due to its complexity. I don't think re-configuring Python logging independently for every job is a good fit.