#!/bin/bash # ################################### # # 文件名称: print.f # 功 能: 日志打印颜色方案 # 用 法: source print.f # 作 者: ithandonglin # 日 期: 2017/11/13 # ################################### # _PRINTHELP_() { echo grep -w "^# 用法:" < "$0" | cut -c9- } _LOGWARN_() { echo -e "[$(date +"%F %T")] [\e[31m\e[5mWARN\e[m] [email protected]" >&2 } _LOGERROR_() { echo -e "[$(date +"%F %T")] [\e[31m\e[5mFAIL\e[m] [email protected]" >&2 } _LOGSUCCESS_() { echo -e "[$(date +"%F %T")] [\e[31m\e[5mEXEC\e[m] [email protected]" >&2 } _LOGINFO_() { echo -e "[$(date +"%F %T")] [\e[31m\e[5mINFO\e[m] [email protected]" >&2 } _LOGRET_() { [ $? -eq "0" ] && _LOGSUCCESS_ ${1} || { _LOGERROR_ ${2};exit 1; } } _LOGNOTEXIT_() { [ $? -eq "0" ] && _LOGSUCCESS_ ${1} || _LOGWARN_ ${2} } _EXECNOROOT_() { [[ $(whoami) == "root" ]] && { false;_LOGRET_ "请在非root用户下执行脚本"; } }
时间: 2024-11-13 10:02:12