So, the option is called log_hostname, and it should be added to /etc/config/system where the "system" section contains the log options.
Ps. which OpenWrt version you are using? The code supporting the hostname option parsing has been there since year 2016 and you code snippet seems to differentiate a bit from the current code.
Anyway, you are correct, I am using 15.05.1 (which is from 2016 also?)
I have a good 15 or so Ubiquiti AirMaxM, all with 'only' 32M memory, I have 4~6M free on 18.06.1 and 6~8M free on 15.05.1, and so far there has not been anything I thought I needed from the newer one for my current network rebuild. (rebuilding with VLAN's for better guest, private, IoT separation, I keep swapping between 18.06.1 and 15.05.1 to try the differences)
While good to know this is automatic in the later versions, I am creating a patch for myself that automatically executes once, and only once, whenever the configuration is restored on 15.05.01.
At the same time, it does nothing if ever restored to 17 or 18:
rc.local:
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
# Replacing log.init with a patched one that adds the -u hostname
# In LEDE/OpenWRT>=17 this is no longer needed, so the pattern I choose is
# such that it does not match those versions, should this config ever be restored there.
file='/etc/init.d/log'
if [ ! -f ${file}.orig ]; then
mv ${file} ${file}.orig
old='procd_set_param command \"$PROG\" -f -r \"$log_ip\" \"${log_port}\" -p \"$pid_file\"'
new='procd_set_param command \"$PROG\" -f -h $(cat \/proc\/sys\/kernel\/hostname) -r \"$log_ip\" \"${log_port}\" -p \"$pid_file\"'
sed "s/${old}/${new}/g" ${file}.orig >${file}
chmod a+x ${file}
fi
exit 0
The whole 15.05 branch is mainly May 2015 code, and has been deprecated ages ago by 17.01 and 18.06 and hopefully soon 19.0x.
The branch date tells you when the release branch has been created. You can assume that features introduced later will usually not be there, as only some stuff gets backported to stable release branches. So, feature done in 2016 is likely not in 15.05...
If you ask help for ancient stuff, please remember to state that explicitly. Otherwise the current advice can be misleading. And of course, the question itself may look strange if you ask for something that is standard feature right now...
You are correct of course. In my defence, I was swapping often between 18 and 15 to try both, and the documentation is/was missing for the 18 version. So the question is/was valid for, and meant for, the latest V18 version as well.
That you are fluent enough to read the source instead of documentation is impressive, and thanks for the help, because it did point me toward a better solution for myself (despite hanging around on an older version).