romana / rlog

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

enhancement: rlog joined config file #14

Open Trickx opened 7 years ago

Trickx commented 7 years ago

I'm working on a project utilising a similar config file syntax as rlog does. The logic consequence was to join them both. It's working, but rlog complains about unkown or malformed settings:

rlog - Malformed line in config file file:line. Ignored. rlog - Unknown or illegal setting name in config file file:line. Ignored.

Having multiple config file for a single application is a nightmare for me. So I decided to comment out corresponding lines in my version of rlog.

What about officially supporting multi function config files instead?

Regards, Trickx

jbrendel commented 7 years ago

Hello!

This could probably be done and would require 'sections' of sorts to be introduced. I don't want to break the old config file format, though.

We could do something like in the .ini file format. But if the first non-blank or non-comment line is NOT a section identifier then we'd still assume it's the old style file format. Rlog could have an '[rlog]' section heading.

Would that work for you?

Trickx commented 7 years ago

Hi Jürgen,

greetings to the most far away location from my perspective :-) Sectioning the config file sounds good to me. Currently the log file, I would like to merge with looks simirlar to the following example. I can easily add an [rlog] section.

Thanks, TriCX

[base]
serial="smartpi160812345"
name="House"

[location]
lat=52.3667
lng=9.7167

[database]
counterdir="/var/smartpi"
dir="/var/smartpi/db"

[device]
i2c_device="/dev/i2c-1"
shared_dir="/var/tmp/smartpi"
shared_file="values"
power_frequency=50

[ftp]
ftp_upload=0
ftp_server=ftp.xxxxx.xx
ftp_user=xxxxxxxxxxx
ftp_pass=xxxxxxxxxxxx
ftp_path=smartpi/

[csv]
decimalpoint=,
timeformat=2006-01-02 15:04:05

[webserver]
port=1080
docroot="/var/smartpi/www"

[mqtt]
mqtt_enabled=0
mqtt_broker_url=""
mqtt_broker_port=""
mqtt_username=""
mqtt_password=""
mqtt_topic=""