#!/bin/sh
########################################################################
# Begin $/opt/midas/bin/logging
#
# Description : Script to provide logging facitilites to other scripts
#               These functions allow a script to log in the style of
#               system software.
#
#               For example usage see shutdown-monitor script.
#
# Authors     : MLA
#
# Version     : 00.00
#
# Notes       : none.
#
########################################################################


########################################################################
#
# Log error messages
#   Generate a system compatible log file name.
#
#   Arguments
#     $1   parent directory of the log file/s. 
#     $2   the base name of the log file.
#
########################################################################
function GenerateLogFileName ( )
{
	date -u +"$1/%Y%m%d %H%M%S - 00000 $2.txt"
}

########################################################################
#
# Log error messages
#   Append a 'Critical' log message to the specified log file.
#
#   Arguments
#     $1   fully qualified log file path.
#     $2   log message content.
#
########################################################################
function LogCritical ( )
{
	echo $( date -u +"%a %b %d %X %Y CRITICAL    : " )$2 >> $1
}

########################################################################
#
# Log warning messages
#   Append a 'Warning' log message to the specified log file.
#
#   Arguments
#     $1   fully qualified log file path.
#     $2   log message content.
#
########################################################################
function LogWarning ( )
{
	echo $( date -u +"%a %b %d %X %Y WARNING     : " )$2 >> $1
}

########################################################################
#
# Log information messages
#   Append a 'Information' log message to the specified log file.
#
#   Arguments
#     $1   fully qualified log file path.
#     $2   log message content.
#
########################################################################
function LogInformation ( )
{
	echo $( date -u +"%a %b %d %X %Y INFORMATION : " )$2 >> $1
}

########################################################################
#
# Log debug
#   Append a 'Debug' log message to the specified log file.
#
#   Arguments
#     $1   fully qualified log file path.
#     $2   log message content.
#
########################################################################
function LogDebug ( )
{
	echo $( date -u +"%a %b %d %X %Y DEBUG       : " )$2 >> $1
}

