brutella / hc

hc is a lightweight framework to develop HomeKit accessories in Go.
Apache License 2.0
1.74k stars 189 forks source link

pluggable logger #187

Closed ripienaar closed 2 years ago

ripienaar commented 3 years ago

Would you be open to accepting a PR that makes the actual logger a pluggable? So I can wrap my projects logger in an interface that I give to hc, this way your logs end up within the logging the controlling project maintains?

Default behaviour would be exactly as is today

If so, I can look to do a PR, just wanted to test the water first.

thanks

brutella commented 2 years ago

If you logger is a log.Logger, can change the hap logger like this.

import(
    hclog "github.com/brutella/hc/log"
    "log"
)

var mylogger *log.Logger
hclog.Debug = &hclog.Logger{mylogger}
hclog.Info = &hclog.Logger{mylogger}