Nom1fan

Bash Logger with colors

Dec 24th, 2024 (edited)
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.35 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. print_color() {
  4.     local color=$1
  5.     local message=$2
  6.     local reset_color='\033[0m' # ANSI escape code to reset color
  7.     echo -e "${color}${message}${reset_color}"
  8. }
  9.  
  10. info() {
  11.     print_color "\033[32m" "INFO: $*"
  12. }
  13.  
  14. warn() {
  15.     print_color "\033[33m" "WARN: $*"
  16. }
  17.  
  18. error() {
  19.     print_color "\033[31m" "ERROR: $*"
  20. }
Tags: BASH Logging
Add Comment
Please, Sign In to add comment