#!/bin/bash


#add messages to /var/log/messages
#auth: Justin.Guo
#version: 1.1
#Useage in your functions: upload_log $FUNCNAME success/error  "your messages"
#e.g.: upload_log $FUNCNAME success "Success!"

upload_log(){
  task=$1
  msg=$3
  if [[ $2 == 'error' ]]; then
    echo "`date "+%b %_d %T"` $HOSTNAME [RC_ERROR] $task $msg" >> /var/log/messages
  elif [[ $2 == 'success' ]]; then
    echo "`date "+%b %_d %T"` $HOSTNAME [RC_SUCCESS] $task $msg" >> /var/log/messages
  else
    echo "`date "+%b %_d %T"` $HOSTNAME [RC_INFO] $task $msg" >> /var/log/messages
  fi
}

