log4bash icon indicating copy to clipboard operation
log4bash copied to clipboard

Working but no color

Open ghost opened this issue 9 years ago • 3 comments

For example, here is my simple script using log4bash.sh

#!/bin/bash

source log4bash.sh

log "COOL"

log_warning "HELP!"
log_info "AWESOME"
log_success "WEWEWEWE"
log_error "ERROR!"

and the output is -

[2016-12-02 22:27:20 UTC] [INFO] COOL 
[2016-12-02 22:27:20 UTC] [WARNING] HELP! 
[2016-12-02 22:27:20 UTC] [INFO] AWESOME 
[2016-12-02 22:27:20 UTC] [SUCCESS] WEWEWEWE 
[2016-12-02 22:27:20 UTC] [ERROR] ERROR!

working fine, but no colo(u)r.

Thanks in advance.

ghost avatar Dec 02 '16 14:12 ghost

I noticed this problem on Linux systems. It comes down to line 19 being a special case for macOS, and it doesn't work right on Linux/BSD/etc. Uncommenting line 18 and removing line 19 might do the job, but I haven't tested, as I rewrote the whole test to work across other shells.

swelljoe avatar Mar 04 '17 00:03 swelljoe

I noticed this problem on Linux systems. It comes down to line 19 being a special case for macOS, and it doesn't work right on Linux/BSD/etc. Uncommenting line 18 and removing line 19 might do the job, but I haven't tested, as I rewrote the whole test to work across other shells.

Hi, It doesn't work on Ubuntu 18.04 Any suggestions ?

TNX

rypz79 avatar Sep 12 '18 07:09 rypz79

I ended up forking and rewriting a bit to make it work on all POSIX shells and remove the Mac OS X-isms. I converted it to use tput for colors, which abstracts the color code so that it works on any system with a correctly configured termcap (and the tput command). My fork is here: https://github.com/swelljoe/slog

My fork doesn't have exactly the same semantics, so you'll need to modify your code a little, if you've been using log4bash.

swelljoe avatar Sep 13 '18 09:09 swelljoe