Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ cron [list|add|delete|deleteall] adds, deletes a custom cron job or del
usb [on|off] turns usb ports on or off
remote [check|status|upgrade|services] helps with treehouses remote android app
[version|commands|allservices]
log <0|1|2|3|4|show|max> gets/sets log level and shows log
log [0|1|2|3|4|show|max|ram [on|off]] gets/sets log level and shows log
blocker <0|1|2|3|4||max> website blocking levels using /etc/hosts
sdbench displays read and write speed of micro SD card
inspire [joke|qotd|random] displays quote based on user input
Expand Down
3 changes: 3 additions & 0 deletions _treehouses
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ treehouses log 4
treehouses log max
treehouses log show
treehouses log show 5
treehouses log ram
treehouses log ram on
treehouses log ram off
treehouses memory
treehouses memory -g
treehouses memory -m
Expand Down
2 changes: 1 addition & 1 deletion modules/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Usage: treehouses
usb [on|off] turns usb ports on or off
remote [check|status|upgrade|services] helps with treehouses remote android app
[version|commands|allservices]
log <0|1|2|3|4|show|max> gets/sets log level and shows log
log [0|1|2|3|4|show|max|ram [on|off]] gets/sets log level and shows log
blocker <0|1|2|3|4||max> website blocking levels using /etc/hosts
sdbench displays read and write speed of micro SD card
inspire [joke|qotd|random] displays quote based on user input
Expand Down
39 changes: 38 additions & 1 deletion modules/log.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
function log2ram {
checkrpi
checkargn $# 1
if [ "$1" = "" ]; then
if [[ $(df -h) != *"log2ram"* ]]; then
echo "log2ram is off"
else
echo "log2ram is on"
fi
elif [ "$1" = "on" ]; then
if [[ $(log2ram) = *off* ]]; then
command log2ram start
fi
echo "Successfully started log2ram"
elif [ "$1" = "off" ]; then
command log2ram stop
echo "Sucessfully stopped log2ram"
else
log_and_exit1 "Error: only '', 'on', and 'off' options supported"
fi
}

# uses logger command to log to /var/log/syslog
# logit "text" "whether or not to write to screen" "logging level"
# e.g. logit "i logged some text"
Expand Down Expand Up @@ -105,6 +127,9 @@ function log {
LOG=max
logit "log X: level set to max" "" "DEBUG"
;;
"ram")
log2ram "$2"
;;
*)
log_and_exit1 "Error: only '0' '1' '2' '3' '4' 'show' 'max' options are supported"
;;
Expand All @@ -114,7 +139,7 @@ function log {

function log_help {
echo
echo "Usage: $BASENAME log <0|1|2|3|4|show|max>"
echo "Usage: $BASENAME log [0|1|2|3|4|show|max|ram [on|off]]"
echo
echo "Example:"
echo " $BASENAME log"
Expand Down Expand Up @@ -146,4 +171,16 @@ function log_help {
echo " $BASENAME log max"
echo " log X: level set to max"
echo
echo " $BASENAME log ram"
echo " log2ram is off"
echo " force logs to be stored in ram and only writes to disk on shutdown"
echo " https://github.com/azlux/log2ram"
echo " Stores logs in 40M (Megabytes) in mount point in memory"
echo
echo " $BASENAME log ram on"
echo " Successfully started log2ram"
echo
echo " $BASENAME log ram off"
echo " Successfully stopped log2ram"
echo
}