sysmodelgen/src/Logger.pm
author William Roberts <williamr@symbian.org>
Wed, 01 Sep 2010 17:12:41 +0100
branchHighFidelityModel
changeset 382 e68d7cc001c2
parent 152 5acf50bbb618
permissions -rw-r--r--
buildverification collection has been deleted from sf/app/techview
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
152
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     1
# Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     2
# All rights reserved.
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     3
# This component and the accompanying materials are made available
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     4
# under the terms of the License "Symbian Foundation License v1.0"
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     5
# which accompanies this distribution, and is available
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     6
# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     7
#
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     8
# Initial Contributors:
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    10
#
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    11
# Contributors:
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    12
#
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    13
# Description:
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    14
#
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    15
package Logger;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    16
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    17
use FindBin;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    18
use lib $FindBin::Bin;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    19
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    20
use LogItem;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    21
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    22
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    23
# -------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    24
# 	ERROR & WARNING CODES
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    25
# -------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    26
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    27
use constant KErrorNone							=> 0;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    28
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    29
use constant KIncorrectSyntax					=> 1;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    30
use constant KFileDoesNotExist					=> 2;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    31
use constant KCannotOpenFile					=> 3;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    32
use constant KBinaryDoesNotExist				=> 7;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    33
use constant KFailure							=> 9;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    34
use constant KNothingToDo							=> 10;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    35
use constant KUnknownError				=> 200;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    36
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    37
# System_Definition.xml error codes:
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    38
use constant KSysDefNotFound					=> 31;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    39
use constant KInvalidSysDefXML					=> 32;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    40
use constant KConfigurationNotFound				=> 33;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    41
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    42
# Global statics:
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    43
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    44
# This is expected to be set by the client code using $Logger::LOGFILE
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    45
# If it's not defined, the logging is done to stdout
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    46
$LOGFILE = "";
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    47
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    48
$SEVERITY = LogItem::ERROR;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    49
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    50
# Forward declarations:
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    51
sub Log($$$$);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    52
sub LogFatal($$$);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    53
sub LogError($$$);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    54
sub LogWarning($$$);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    55
sub LogInfo($$$);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    56
sub LogRaw($);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    57
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    58
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    59
# Subroutine:   Log
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    60
# Purpose:      Logs to the screen
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    61
# Input:        Messsage, Module Code, Severity
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    62
# Output:       None
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    63
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    64
sub Log($$$$)
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    65
	{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    66
	my $message = $_[0];
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    67
	my $callingModule = $_[1];
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    68
	my $severity = $_[2] ? $_[2] : LogItem::INFO;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    69
	my $depth = $_[3] ? $_[3] : 0;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    70
	
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    71
	# log this only if its severity level is less than or equal to the user-defined level:
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    72
	#  -w1: errors only (default)
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    73
	#  -w2: warnings as well as errors
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    74
	#  -w3: info messages, warnings and errors.
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    75
	return if $severity > $SEVERITY;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    76
	
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    77
	my $code = $callingModule;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    78
	my $logItem = new LogItem(msg => $message, code => $code, severity => $severity, depth => $depth);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    79
	&WriteToFile($logItem->LogText());
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    80
	}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    81
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    82
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    83
# Subroutine:   LogFatal
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    84
# Purpose:      Logs to the screen
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    85
# Input:        Message Module Code
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    86
# Output:       None
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    87
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    88
sub LogFatal($$$)
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    89
	{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    90
	my $message = $_[0];
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    91
	my $callingModule = $_[1];
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    92
	my $depth = $_[2] ? $_[2] : 0;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    93
	my $exitCode = $_[3] ? $_[3] : KFailure;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    94
	&Log("Fatal! ".$message, $callingModule, LogItem::ERROR, $depth);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    95
	exit $exitCode;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    96
	}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    97
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    98
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    99
# Subroutine:   LogError
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   100
# Purpose:      Logs to the screen
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   101
# Input:        Message Module Code
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   102
# Output:       None
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   103
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   104
sub LogError($$$)
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   105
	{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   106
	my $message = $_[0];
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   107
	my $callingModule = $_[1];
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   108
	my $depth = $_[2] ? $_[2] : 0;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   109
	&Log($message, $callingModule, LogItem::ERROR, $depth);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   110
	}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   111
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   112
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   113
# Subroutine:   LogWarning
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   114
# Purpose:      Logs to the screen
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   115
# Input:        Message Module Code
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   116
# Output:       None
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   117
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   118
sub LogWarning($$$)
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   119
	{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   120
	# first check the severity level:
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   121
	return if $SEVERITY < LogItem::WARNING;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   122
	
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   123
	my $message = $_[0];
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   124
	my $callingModule = $_[1];
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   125
	my $depth = $_[2] ? $_[2] : 0;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   126
	&Log($message, $callingModule, LogItem::WARNING, $depth);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   127
	}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   128
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   129
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   130
# Subroutine:   LogInfo
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   131
# Purpose:      Logs to the screen
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   132
# Input:        Message Module Code
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   133
# Output:       None
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   134
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   135
sub LogInfo($$$)
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   136
	{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   137
	# first check the severity level:
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   138
	return if $SEVERITY < LogItem::INFO;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   139
	
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   140
	my $message = $_[0];
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   141
	my $callingModule = $_[1];
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   142
	my $depth = $_[2] ? $_[2] : 0;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   143
	&Log($message, $callingModule, LogItem::INFO, $depth);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   144
	}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   145
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   146
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   147
# Subroutine:   LogRaw
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   148
# Purpose:      Logs a piece of raw text to the screen
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   149
# Input:        Messsage string
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   150
# Output:       None
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   151
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   152
sub LogRaw($)
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   153
	{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   154
	# only log raw text if the warning level is on info - i.e. the most verbose:
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   155
	return if $SEVERITY < LogItem::INFO;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   156
	&WriteToFile($_[0]);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   157
	}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   158
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   159
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   160
# Subroutine:   LogList
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   161
# Purpose:      Logs a list of log items
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   162
# Input:        array of logs starting with ERROR, WARNING or Note
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   163
# Output:       None
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   164
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   165
sub LogList
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   166
	{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   167
	foreach my $log (@_) 
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   168
		{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   169
		$log.="\n";
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   170
		if($log=~s/^ERROR:\s*//)
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   171
			{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   172
			&LogError($log,KUnknownError,1);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   173
			}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   174
		elsif($log=~s/^WARNING:\s*//)
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   175
			{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   176
			&LogWarning($log,KUnknownError,1);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   177
			}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   178
		elsif($log=~s/^Note:\s*//)
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   179
			{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   180
			&LogInfo($log,KUnknownError,1);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   181
			}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   182
		else
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   183
			{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   184
			&LogRaw($log);
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   185
			}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   186
		}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   187
	}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   188
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   189
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   190
# Subroutine:   WriteToFile
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   191
# Purpose:      
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   192
# Input:        A message string
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   193
# Output:       None
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   194
#-------------------------------------------------------------------------------------------------
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   195
sub WriteToFile()
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   196
	{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   197
	my $message = shift;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   198
	if ($LOGFILE ne "")
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   199
		{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   200
		open(LOGFILE, ">> $LOGFILE") or die "Can't open the log file '$LOGFILE': $!";
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   201
		print LOGFILE $message;
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   202
		}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   203
	else
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   204
		{
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   205
		print $message; # print to stdout
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   206
		}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   207
	}
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   208
5acf50bbb618 Preview version of system model generator which supports 3.0 syntax
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   209
1;