romana / rlog

A simple Golang logger without external dependencies
Apache License 2.0
39 stars 13 forks source link

Allow for reconfiguration at runtime via modifying a config file #12

Closed jbrendel closed 7 years ago

jbrendel commented 7 years ago

This will also add the general ability to configure rlog via config file.

Config files by default should be at $RLOG_CONFIG_ROOT/filename.conf

By default, RLOG_CONFIG_ROOT is assumed to be "/etc/rlog/"

filename is just the filename of the executable. The default of looking for filename.conf can be overwritten with the RLOG_CONFIG_FILE variable, which can be used to set an absolute path to a full filename. That way, multiple executables can utilize the same config file.

rlog will check the config file every N seconds for changes.

The config file simply contains whatever you would have as environment variable assignments:

RLOG_LOG_LEVEL=INFO
RLOG_TRACE_LEVEL=3
...

Environment variables provided at the start of a process take precedence over whatever is in the config file, unless the line in the config file starts with a "!", like so:

RLOG_LOG_LEVEL=INFO
!RLOG_TRACE_LEVEL=3
...

When rlog encounters a log message, it should check how long ago it last checked the config file. If it's more than RLOG_CONF_CHECK_INTERVAL seconds ago, then it should re-read the config file again.

jbrendel commented 7 years ago

Done