Skip to content

Instantly share code, notes, and snippets.

@fragolinux
Last active May 24, 2019 20:38
Show Gist options
  • Save fragolinux/3081ff65c420a329f95b1e4e38f3e771 to your computer and use it in GitHub Desktop.
Save fragolinux/3081ff65c420a329f95b1e4e38f3e771 to your computer and use it in GitHub Desktop.
# if you don't have it, install ccze
sudo apt-get install -y ccze
# add this alias at the end of your $HOME/.bashrc
# idea from: https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-log
alias nrlog="sudo journalctl -f -n 50 -u nodered -o cat | ccze -A"
# source .bashrc, to make the alias available immediately, or just reboot your system...
. $HOME/.bashrc
# use it... open a console (putty on windows, for example), and just launch:
nrlog
# example: http://i.imgur.com/4d7Wh4b.jpg
# a test flow, from: https://groups.google.com/d/msg/node-red/aVeNk4SJik4/Zti_BS8hpK0J
[{"id":"efc40aea.7ff448","type":"function","z":"868a1b14.f84f08","name":"Just testing","func":"//Just for testing console.log() workaround\n\n// msg.payload = context.global.mydebug;\n// return msg;\n\nfunction mydebug(debugtext) {\n\tdebugflag = context.global.mydebug;\n\tif (debugflag == \"TRUE\") {\n\t console.log(debugtext+\"\\n\"); \n\t} else {\n//\t return [ msg, null ];\n\t}\n\n}\n\nmydebug(\"Debugging is TRUE\"); \n\nswitch (msg.topic) {\n case \"One\":\n msg.payload = \"Got input One\";\n mydebug(msg.payload); \n msg = null;\n break;\n case \"Two\":\n msg.payload = \"Got input Two\";\n mydebug(msg.payload); \n msg = null;\n break;\n \n default:\n \tmydebug(\"Apparently I got an Invalid Topic\"); \n msg = null;\n \tbreak;\n\n} \nreturn msg;","outputs":1,"x":458.42016983032227,"y":315.0924482345581,"wires":[["aca9f2bf.42a28"]]},{"id":"d1023fe.45b6fc","type":"inject","z":"868a1b14.f84f08","name":"","topic":"One","payload":"1","payloadType":"string","repeat":"","crontab":"","once":false,"x":142.42015838623047,"y":277.52099895477295,"wires":[["efc40aea.7ff448"]]},{"id":"420c8226.6985bc","type":"inject","z":"868a1b14.f84f08","name":"","topic":"Two","payload":"2","payloadType":"str","repeat":"","crontab":"","once":false,"x":142.13443756103516,"y":318.23529624938965,"wires":[["efc40aea.7ff448"]]},{"id":"ce00e7a9.c34248","type":"comment","z":"868a1b14.f84f08","name":"Just a test case","info":"Testing mydebug flag.\nI am just interested in the console.log() stuff","x":139.14286041259766,"y":240.4285888671875,"wires":[]},{"id":"1c50a59b.77253a","type":"inject","z":"868a1b14.f84f08","name":"","topic":"Invalid Topic","payload":"99","payloadType":"string","repeat":"","crontab":"","once":false,"x":165.5714340209961,"y":354.71428775787354,"wires":[["efc40aea.7ff448"]]},{"id":"aca9f2bf.42a28","type":"debug","z":"868a1b14.f84f08","name":"","active":true,"console":"false","complete":"false","x":619.5,"y":315.16665999094636,"wires":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment