SNO's ColoredLog for Windows/Linux/Mac using GUI/docker

Thanks for this @BrightSilence. This is a pretty neat way to visualize the logs in the terminal. And thanks to @nerdatwork for getting this started.

I will add that running the logs through tail into the awk script give the same visual result on my system. I have my logs redirected to a file on a USB thumb drive. When just tailing the logs it displays line by line as they are written to the file. Processing through awk it displays in blocks of 15-20 lines at a time every 20 seconds or so. I would assume it’s a performance issue, but CPU is nearly 0 for everything but the node itself, and the I/O load on the USB thumb drive is too low to even register. An odd problem.

This is on a 4GB Rock64, Debian Stretch, connected via Putty. Happens in standard terminal sessions and within a tmux session. Not that it bothers me that much, but for the visual factor (which is what this is all about, right?) it would certainly look nice if the lines flowed onto the screen as they are written to the log.

It looks like it’s caused by the pipe. The data is being buffered. I’m not sure why that’s not happening by default on my system, but this page has some suggestions to fix that.

I think prefixing the command with this would work for most.

stdbuf -o0 

Thanks for the research and info! In my case adding this to the script had no affect on the behaviour. I’ll try to look into it myself when I get some time.

–edit–
I tried prefixing the awk part of the script with stdbuf -o0, as suggested in the second solution on the page you linked with the same non-result.

Thanks for the feedback, I removed it again from the scripts I posted above until we have a working solution. Unfortunately I can’t help you test as my system doesn’t have this issue to begin with.

You could try unbuffering everything with

stdbuf -i0 -o0 -e0

And perhaps try it on both commands (at the start and before awk). If that doesn’t work, this command definitely isn’t the solution.

Tried it and it doesn’t seem to work on my system.

I tried all combinations of stdbuf before tail, before awk, and before both. No dice. I tried installing the expect package, so as to use the unbuffer command as suggested in some forum posts, but it seems a dependency is missing for my system.

–edit–
I found the missing dependency for unbuffer, and it works! I added unbuffer -p before the awk command. The top of my script now looks as follows:

tail -F /mnt/logs-usb/storj1/storagenode1.log | unbuffer -p awk '
2 Likes

Just wondering if you have tried powershell at all ?

I did not try powershell. In honesty, I saw Powershell and assumed you were running the script on windows, not realizing that powershell is available as a package for linux.

I figured that out after reading comments which I think assumed powershell won’t work in Linux. My initial logic was that interested parties would at least visit the github url that has all the necessary information.

This also taught me how to make the first post informative enough so users won’t have to assume anything.
I wanted to reduce redundancy at first but then giving everything in first post is the right way to go.

I have tested this using WSL too and works like a charm. All logs are shown without any delay with almost 0% CPU usage.

As seen using WSL :arrow_double_down:

just tried it and it works perfectly now…

had a bit of trouble getting unbuffer to work… ended up finding it was part of a package called expect

https://manpages.debian.org/stretch/expect/index.html

after doing an apt install expect, and adding unbuffer -p to the awk command, fixed it.
and just checked both tail and docker version both works

@nerdatwork yeah i really should try yours out and one point also…
no doubt powershell would make better sense because it’s cross platform and most likely more versatile … xD

I tried installing powershell on my system but it gives me this error:

Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package powershell

I’ll look into it tomorrow but if you guys have an idea of what it could be it would save me some research :laughing:
I’m running an odroid with Ubuntu 18.04 LTS

you don’t have the right name for it… (seems to be a trend)
nope… close tho… you need to add a microsoft repo first… then you can apt install powershell

wops that was the debian link… same url tho… should also work

says you should use snapd whatever that is…

Its literally in the first post of how to install it.

3 Likes

That’s what I did when I followed the instructions on the GitHub page but something must have gone wrong.

You could screenshot the terminal with the commands you used so we all can troubleshoot it.

PowershellDebug
there’s a screenshot of the terminal, everything looks fine to me until the last step.

This is when I tried it again, that’s why ‘universe’ is already enabled.

i think apt-get is the old version…
maybe if you try using just apt

has worked for me once in a while… when stuff didn’t want to work.
don’t that is the case here tho…

on another note… the get:10 package repo seems to download ubuntu 16.04 package
maybe microsoft made a mistake… you might need to put the correct url or whatever directly into the repo … configuration file…

aside from that i got no clue… but it’s usually always the repo stuff that seems to go wrong for me…

Have you tried the direct download then ?

sudo dpkg -i powershell-lts_7.0.3-1.ubuntu.18.04_amd64.deb
sudo apt-get install -f

the first command throws this error:

dpkg: error: cannot access archive ‘powershell-lts_7.0.3-1.ubuntu.18.04_amd64.deb’: No such file or directory

And only using apt as suggested by @SGC gives the same result as using apt-get

The dpkg -i command fails with unmet dependencies. The next command, apt-get install -f resolves these issues then finishes configuring the PowerShell package.