-
Notifications
You must be signed in to change notification settings - Fork 13
Changing config on the fly
Sealog was designed to be as stateless as it could be. So there is no 'Initialization' step, you just import Sealog and you immediately can log and do all operations. Then, if you want to change something, you create a new config and call 'SetConfig' func. You can call it any amount of times.
We even have a test, that performs long-time config switching in 1000 multiple goroutines that log messages and switch config after each message.
It is located here: sealog/test/stressconfig
The short answer is simple: call SetConfig with a new config at any moment of time. But the main thing here is to provide such functionality to your application users. For example, if you would like to change logging configuration of your server on-the-fly without restarting it, you need to create some kind of web-interface with a config text box and a 'submit' button that would consequently call 'log.ConfigFromBytes(...)' and 'log.SetConfig'. If the ConfigFromBytes returned an error, like config syntax error, you should create a corresponding error web-page response.
Another option is to check whether the config file changed, and if so, create a config from new file bytes and call 'SetConfig' if new config doesn't contain any errors. We are going to provide such config update checker as a helper utility later.