【Shell】公共类-logger

#!/bin/bash

function debug()
{   
    date=`date +%Y/%m/%d-%H:%M:%S`
    #echo -e "[DEBUG]\t${date} "········ "$*"
    echo -e "\033[37m[DEBUG]\t${date} "··· "\033[0m\033[37m$*\033[0m"
}
function info()
{
    date=`date +%Y/%m/%d-%H:%M:%S`
    #echo -e "[INFO]\t${date} "········ "$*"
    echo -e "\033[32m[INFO]\t${date} "··· "\033[0m\033[32m$*\033[0m"
}
function warn()
{
    date=`date +%Y/%m/%d-%H:%M:%S`
    #echo -e "[WARN]\t${date} "········ "$*"
    echo -e "\033[33m[WARN]\t${date} "··· "\033[0m\033[33m$*\033[0m"
}
function error()
{
    date=`date +%Y/%m/%d-%H:%M:%S`
    #echo -e "[ERROR]\t${date} "··· "$*"
    echo -e "\033[31m[ERROR]\t${date} "··· "\033[0m\033[31m$*\033[0m"
}

debug "this is a debug string"
info "this is a test string"
error "this is a error info"

相关推荐