//-----------------------------------------------------------------------------
// ILogExample.js file
//-----------------------------------------------------------------------------
// There is described the usage of the ILog object in the example.
//-----------------------------------------------------------------------------
//@ Start Example
// Creating the database connection
var Connector = new ActiveXObject('TSDskObjectLibrary.DskConnector');
var FileSystemObject = new ActiveXObject('Scripting.FileSystemObject');
var StringsList = new ActiveXObject('TSObjectLibrary.StringsList');
// Message displaying function
function ShowMessage(Str) {
for (var i = 1; i < arguments.length; i++ ) {
Str = Str.replace(new RegExp('%' + i), arguments[i]);
}
WScript.Echo(Str);
}
// Function of the reading and displaying the log file content
function ShowLog(Log) {
var File = FileSystemObject.GetFile(Log.FileName);
var Stream = File.OpenAsTextStream(1, -2);
while (!Stream.AtEndOfStream) {
StringsList.Add(Stream.ReadLine());
}
ShowMessage(StringsList.Text);
}
if (Connector.Login("Example of the Ilog use")) {
// Use of the connection object's log
var Log = Connector.Log;
// Displaying the log file path
ShowMessage("System log recording file: %1", Log.FileName);
// Message types
var lmtInformation = 0;
var lmtWarning = 1;
var lmtError = 2;
// Recording messages of the different type
Log.Write(lmtInformation, "Information");
Log.Write(lmtWarning, "Warning");
Log.Write(lmtError, "Error");
// Displaying the log file content
ShowLog(Log);
// The log file cleaning
Log.Clear();
// Additional information for the recording to the system log
var MessageData = "";
// Flags of transition to the following system log level
var NewLevel = true;
var CurrentLevel = false;
// Recording the message tree to the system log
Log.WriteToSystemLog(lmtWarning, '1', "The message of the first level", MessageData, CurrentLevel);
Log.WriteToSystemLog(lmtWarning, '1.1', "The message of the second level", MessageData, NewLevel);
Log.CompleteSystemLogLevel();
Log.WriteToSystemLog(lmtWarning, '1.2', "The message of the second level", MessageData, NewLevel);
Log.CompleteSystemLogLevel();
Log.WriteToSystemLog(lmtWarning, '1.3', "The message of the second level", MessageData, NewLevel);
Log.CompleteSystemLogLevel();
Log.CompleteSystemLogLevel();
Log.WriteToSystemLog(lmtWarning, '2', "The message of the first level", MessageData, CurrentLevel);
Log.WriteToSystemLog(lmtWarning, '2.1', "The message of the second level", MessageData, NewLevel);
Log.CompleteSystemLogLevel();
Log.WriteToSystemLog(lmtWarning, '2.2', "The message of the second level", MessageData, NewLevel);
Log.WriteToSystemLog(lmtWarning, '2.2.1', "The message of the third level", MessageData, NewLevel);
}
//@ End Example
|
Copyright (с) Terrasoft 2002-2007.
|