fanshim-python icon indicating copy to clipboard operation
fanshim-python copied to clipboard

Added basic fan status logging

Open FlorentLM opened this issue 5 years ago • 2 comments

Added basic fan status logging for use with external metrics collectors.

Example for Telegraf:

[[inputs.file]]
  files = ["/var/log/fanshim_status"]
  name_override = "fanshim_status"
  data_format = "value"
  data_type = "integer"

FlorentLM avatar Feb 12 '20 17:02 FlorentLM

Thanks for taking the time to PR this.

It seems like a worthwhile addition, but should probably be paired with a new argument that disables logging by default and allows users to enable it. Something like:

parser.add_argument('--logging', action='store_true', help='Enable logging')

Additionally it could be worth using Python's logging module so log entries are implicitly timestamped, see: https://docs.python.org/3/library/logging.html

A complete implementation, I think, would use logging coupled with a configurable logging-level so that perhaps warnings are generated for fan on/off events and info messages are generated containing the info currently output when args.verbose is set.

If you're up for turning this PR into a more concerted learning effort (I'm making assumptions - based on this being your first PR - that Python might be new to you!) then I'm happy to guide you through these changes.

Gadgetoid avatar Feb 24 '20 16:02 Gadgetoid

Sure, these are good points! This was initially very basic, as for my own purpose I really only needed to know when the fan was on or off for Telegram, I tried to add as little code as possible. But your ideas are definitely needed for a more public implementation, yes.

I'm totally up for improving this PR, I'll do that as soon as I have some time.

PS - no worries, Python is not new to me, it'll be fine :) But thanks!

FlorentLM avatar Feb 28 '20 16:02 FlorentLM