mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 03:12:55 +09:00
feature #575: added severities to log messages
This commit is contained in:
1 parent
a931140e9d
commit
bcbcadd9e1
2 files changed
+52
-4
No files matched your search
@@ -103,9 +103,38 @@ class OpenNebulaDriver < ActionManager
|
||||
# be automatically splitted by lines.
|
||||
# -------------------------------------------------------------------------
|
||||
def log(number, message)
|
||||
in_error_message=false
|
||||
msg=message.strip
|
||||
msg.each_line {|line|
|
||||
send_message("LOG", "-", number, line.strip)
|
||||
severity='I'
|
||||
|
||||
l=line.strip
|
||||
|
||||
if l=='ERROR MESSAGE --8<------'
|
||||
in_error_message=true
|
||||
next
|
||||
elsif l=='ERROR MESSAGE ------>8--'
|
||||
in_error_message=false
|
||||
next
|
||||
else
|
||||
if in_error_message
|
||||
severity='E'
|
||||
elsif line.match(/^(ERROR|DEBUG|INFO):(.*)$/)
|
||||
line=$2
|
||||
case $1
|
||||
when 'ERROR'
|
||||
severity='E'
|
||||
when 'DEBUG'
|
||||
severity='D'
|
||||
when 'INFO'
|
||||
severity='I'
|
||||
else
|
||||
severity='I'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
send_message("LOG", severity, number, line.strip)
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -42,16 +42,35 @@ function log_date
|
||||
$DATE +"%a %b %d %T %Y"
|
||||
}
|
||||
|
||||
# Logs a message
|
||||
# Logs a message, alias to log_info
|
||||
function log
|
||||
{
|
||||
echo "$SCRIPT_NAME: $1" 1>&2
|
||||
log_info $1
|
||||
}
|
||||
|
||||
# Log function that knows how to deal with severities and adds the
|
||||
# script name
|
||||
function log_function
|
||||
{
|
||||
echo "$1: $SCRIPT_NAME: $2" 1>&2
|
||||
}
|
||||
|
||||
# Logs an info message
|
||||
function log_info
|
||||
{
|
||||
log_function "INFO" "$1"
|
||||
}
|
||||
|
||||
# Logs an error message
|
||||
function log_error
|
||||
{
|
||||
log "ERROR: $1"
|
||||
log_function "ERROR" "$1"
|
||||
}
|
||||
|
||||
# Logs a debug message
|
||||
function log_debug
|
||||
{
|
||||
log_function "DEBUG" "$1"
|
||||
}
|
||||
|
||||
# This function is used to pass error message to the mad
|
||||
|
||||
Reference in new issue
Block a user