Stoppt die Vorratsdatenspeicherung! Jetzt klicken & handeln!Willst du auch bei der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien:

Class CLogger API

Class for abstract logging to one or more logging facilities. Valid facilities are:

Note that this class does not do any error handling at all. Taking care of errors is entirely up to the calling script.

Version:

2.0, 2011-03-13

Author:

Ansgar Wiechers <ansgar.wiechers@planetcobalt.net>

Property Summary

Debug

Enable or disable debug logging.


IncludeTimestamp

Enable or disable timestamping of log messages.


LogFile

Enable or disable logging to a file by setting or unsetting the log file name.


LogToConsole

Enable or disable logging to desktop/console.


LogToEventlog

Enable or disable logging to the Eventlog.


LogToFile

Indicates whether logging to a file is enabled or disabled.


Overwrite

Enable or disable overwriting of log files.


Separator

Separate the fields of log file entries with the given character.

Method Summary

Log(msg)

An alias for LogInfo().


LogDebug(msg)

Log message with log level "Debug".


LogError(msg)

Log message with log level "Error".


LogInfo(msg)

Log message with log level "Information".


LogWarning(msg)

Log message with log level "Warning".

Property Detail

Debug

Debug
read-write

Enable or disable debug logging. If enabled, debug messages (i.e. messages passed to the LogDebug() method) are logged to the enabled facilities. Otherwise debug messages are silently discarded. This property is disabled by default.


IncludeTimestamp

IncludeTimestamp
read-write

Enable or disable timestamping of log messages. If enabled, the current date and time is logged with each log message. The default is to not include timestamps. This property has no effect on Eventlog logging, because eventlog entries are always timestamped anyway.


LogFile

LogFile
read-write

Enable or disable logging to a file by setting or unsetting the log file name. Logging to a file ie enabled by setting this property to a non-empty string, and disabled by setting it to an empty string. If the file doesn't exist, it will be created automatically. By default this facility is disabled.

Note that you MUST set the property Overwrite to False BEFORE setting this property to prevent an existing file from being overwritten!

See also:

Overwrite


LogToConsole

LogToConsole
read-write

Enable or disable logging to desktop/console. Depending on whether the script is run via wscript.exe or cscript.exe, the message is either displayed as a MsgBox() popup or printed to the console. This facility is enabled by default when the script is run interactively.

Console output is printed to StdOut for Info and Debug messages, and to StdErr for Warning and Error messages.


LogToEventlog

LogToEventlog
read-write

Enable or disable logging to the Eventlog. If enabled, messages are logged to the Application Eventlog. By default this facility is enabled when the script is run non-interactively, and disabled when the script is run interactively.

Logging messages to this facility produces eventlog entries with source WSH and one of the following IDs:


LogToFile

LogToFile
read-only

Indicates whether logging to a file is enabled or disabled. The log file facility is disabled by default. To enable it, set the LogFile property to a non-empty string.

See also:

LogFile


Overwrite

Overwrite
read-write

Enable or disable overwriting of log files. If disabled, log messages will be appended to an already existing log file (this is the default). The property affects only logging to a file and is ignored by all other facilities.

Note that changes to this property will not affect already opened log files until they are re-opened.

See also:

LogFile


Separator

Separator
read-write

Separate the fields of log file entries with the given character. The default is to use tabulators. This property affects only logging to a file and is ignored by all other facilities.

Raises:

Separator must be a single character (5)

See also:

http://msdn.microsoft.com/en-us/library/xe43cc8d (VBScript Run-time Errors)

Method Detail

Log

Public Log(msg)

An alias for LogInfo(). This method exists for convenience reasons.

Parameters:

msg - The message to log.

See also:

LogInfo(msg)


LogDebug

Public LogDebug(msg)

Log message with log level "Debug". These messages are logged only if debugging is enabled, otherwise the messages are silently discarded.

Parameters:

msg - The message to log.

See also:

Debug


LogError

Public LogError(msg)

Log message with log level "Error".

Parameters:

msg - The message to log.


LogInfo

Public LogInfo(msg)

Log message with log level "Information".

Parameters:

msg - The message to log.


LogWarning

Public LogWarning(msg)

Log message with log level "Warning".

Parameters:

msg - The message to log.

Created with VBSdoc.