How do you write a log from the ash (bash) that can be viewed in the logread? Ive tried using the logger command, but it doesnt work.
Topic: Logging to logread
The content of this topic has been archived on 28 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.
Page 1 of 1
logger "Log message"
Example from my wifi wps button:
root@OpenWrt:~# cat /etc/rc.button/wps
#!/bin/sh
if [ "$ACTION" = "pressed" -a "$BUTTON" = "wps" ]; then
logger "WPS button pressed, looking for active radios"
echo "255" > /sys/devices/platform/leds-gpio/leds/netgear:green:wps/brightness
for dir in /var/run/hostapd*; do
[ -d "$dir" ] || continue
logger "WPS activated for: $dir"
hostapd_cli -p "$dir" wps_pbc
done
sleep 10
echo "0" > /sys/devices/platform/leds-gpio/leds/netgear:green:wps/brightness
fi
root@OpenWrt:~# logread | tail -n 5
Mon Apr 14 19:27:13 2014 daemon.notice netifd: Network device 'wlan0' link is up
Mon Apr 14 19:27:13 2014 kern.info kernel: [95992.850000] br-lan: port 3(wlan1) entered forwarding state
Mon Apr 14 19:27:14 2014 kern.info kernel: [95993.850000] br-lan: port 2(wlan0) entered forwarding state
Mon Apr 14 19:29:22 2014 user.notice root: WPS button pressed, looking for active radios
Mon Apr 14 19:29:22 2014 user.notice root: WPS activated for: /var/run/hostapd
And you can also set the visible source for the user.notice class:
root@OpenWrt:~# logger -t "source" message line
root@OpenWrt:~# logread | tail -n 2
Mon Apr 14 19:29:22 2014 user.notice root: WPS activated for: /var/run/hostapd
Mon Apr 14 19:32:32 2014 user.notice source: message line
(Last edited by hnyman on 14 Apr 2014, 17:33)
A bit around, but you can try
ubus call log write '{ "event": "Foo" }'
;) What's wrong with "logger" for you?
(Last edited by Zajec on 14 Apr 2014, 17:32)
Yeah, my syntax was wrong, i was writing 'logger message' instead of 'logger "message"'
Thanks for your help!
The discussion might have continued from here.
Page 1 of 1