Hi Aurélien, On Wed, Oct 18, 2023 at 09:32:19AM +0200, Aurelien DARRAGON wrote: > Hi Guys, > > I also have a suggestion, while at it: > > SEND_ERR() which is used to report unexpected Lua errors (because of > improper API usage, or due to external factors such as IO/memory issues) > currently does a stderr duplication as in hlua_sendlog() > > I'm thinking that it could be useful to make this configurable too, but > maybe independently from the txn:log() (hlua_sendlog()) logic since in > this case for errors we might be more interested in stderr reporting by > default instead of regular logging?
I don't know. I tend to think that keeping technical errors (allocation, internal bugs etc) on stderr is not a bad thing, as they should never flood. However user manipulation errors, data processing errors and API errors (which can result from a bug in a lua script) should not be sent there by default. Thus I don't think we need an extra option, maybe we should just recheck which call places use SEND_ERR() and maybe some of them should just use ha_alert() without considering the option and other ones should consider the option. > One last thing, SEND_ERR() reports to stderr through ha_alert() and > hlua_sendlog() does it through fprintf(stderr, ) by appending a static > header containing the log level, the date and the pid: maybe we should > try to unify those outputs as well? I'm not sure anyone really *wants* to have to configure all that stuff for error reporting. Maybe the format is not great, maybe it should use send_log() etc, quite frankly I don't know as I have not visited that part. But my gut feeling is that it shouldbe as little specific as possible and use the standard features, mechanisms and formats that other subsystems already use. For example when a proxy is stopped it emits alerts, on stderr and in logs. I think that there's no reason Lua would use a different approach. Thanks, Willy