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