【Shell】公共类-logger

余生颓废 提交于 2020-01-28 16:19:43
#!/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"

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!