|
LogFileXhtml Class
This class establishes a rich XHTML log file. Then, lines can be added in three
flavors ( error, nonerror, and complete).
Namespace: SobekCM.Tools.LogsAssembly: SobekCM_Tools (in SobekCM_Tools.dll) Version: 4.10.0.0 (4.10.0)
Syntax
C# |
---|
public class LogFileXhtml |
Remarks
Examples
The example below demonstrates using this object in the basic format, without adding new styles.
| Copy |
---|
<SPAN class="lang">[C#]</SPAN>
using System;
using System.IO;
using GeneralTools.Logs;
namespace GeneralTools
{
public class LogFileXHTML_Example_1
{
static void Main()
{
LogFileXHTML myLogger = new LogFileXHTML( "c:\\example.log.html", "Log File XHTML Example", "Class Library Example" );
myLogger.New();
myLogger.Open();
int files = -1, folderNumber = 1;
foreach ( string thisDir in Directory.GetDirectories("C:\\") )
{
try
{
files = Directory.GetFiles(thisDir).Length;
}
catch
{
files = -1;
}
if ( files == -1 )
myLogger.AddError( "ERROR! Unable to determine the number of files in folder " + thisDir );
else
myLogger.AddNonError( "Folder " + thisDir + " is the " + folderNumber + "th folder found had " + Directory.GetFiles(thisDir).Length + " files." );
folderNumber++;
}
myLogger.AddComplete( folderNumber + " Total Folders Found and " + myLogger.ErrorCount + " Errors Found!" );
myLogger.Close();
myLogger.MailSMTP( "Example", "marsull@mail.uflib.ufl.edu" );
}
}
} |
Below is what the output file's text looks like. To see it in HTML, click here.
| Copy |
---|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<! Log file produced automatically by C# program LogFileXHTML.cs >
<! Developed by Mark V Sullivan, November 2002 >
<head>
<title> Log File XHTML Example </title>
<! Values used by LogFileXHTML >
<META NAME="Next_Position" CONTENT="3245">
<META NAME="Date_Created" CONTENT="11/12/2003 8:43:45 PM-">
<META NAME="Row_Header" CONTENT="">
<META NAME="Date_Stamping" CONTENT="True">
<META NAME="Error_Count" CONTENT="1">
<META NAME="Application" CONTENT="Class Library Example">
<! Style Sheet Definitions >
<style type="text/css">
.logFileName { font-size: "x-large"; text-align: "center"; font-weight: "bold"; font-family: "Arial" }
.logEntry { color: "black"; font-family: "Arial"; font-size: "15"; }
.errorLogEntry { color: "red"; font-family: "Arial"; font-size: "15"; <!strong> }
.completedLogEntry { color: "blue"; font-family: "Arial"; font-size: "15"; <!strong> }
</style>
</head>
<body>
<div class="logFileName">Log File XHTML Example</div>
<br /><hr /><br />
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\adaptec is the 1th folder found had 1 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\ADOBEAPP is the 2th folder found had 0 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Aerials is the 3th folder found had 0 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\comcheck is the 4th folder found had 0 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Content SDK is the 5th folder found had 5 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\dell is the 6th folder found had 0 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Documents and Settings is the 7th folder found had 0 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Inetpub is the 8th folder found had 0 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\My Music is the 9th folder found had 0 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\OfficeScan NT is the 10th folder found had 95 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Perl is the 11th folder found had 2 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Processing is the 12th folder found had 0 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\Program Files is the 13th folder found had 2 files.</div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\RECYCLER is the 14th folder found had 0 files.</div>
<div class="errorLogEntry"> 11/12/2003 8:43:49 PM - <strong>ERROR! Unable to determine the number of files in folder C:\System Volume Information</strong></div>
<div class="logEntry"> 11/12/2003 8:43:49 PM - Folder C:\WINNT is the 16th folder found had 159 files.</div>
<div class="completedLogEntry"> 11/12/2003 8:43:49 PM - <strong>17 Total Folders Found and 1 Errors Found!</strong></div>
<br /><hr /><br />
</body>
</html> |
Inheritance Hierarchy
Constructors
| Name | Description |
---|
| LogFileXhtml(String) | Constructor which builds a new LogFileXHTML object | | LogFileXhtml(String, Boolean) | Constructor which builds a new LogFileXHTML object | | LogFileXhtml(String, String) | Constructor which builds a new LogFileXHTML object | | LogFileXhtml(String, String, Boolean) | Constructor which builds a new LogFileXHTML object | | LogFileXhtml(String, String, String) | Constructor which builds a new LogFileXHTML object | | LogFileXhtml(String, String, String, Boolean) | Constructor which builds a new LogFileXHTML object | | LogFileXhtml(String, String, String, String) | Constructor which builds a new LogFileXHTML object | | LogFileXhtml(String, String, String, String, Boolean) | Constructor which builds a new LogFileXHTML object |
Methods
| Name | Description |
---|
| AddComplete | Adds a line indicating completeness to the log file. | | AddError | Adds an error line to the current log file. | | AddNewStyle(String, String) | [NOT YET FULLY IMPLEMENTED]
Create a new style for this log file. | | AddNewStyle(String, String, Boolean) | [NOT YET FULLY IMPLEMENTED]
Create a new style for this log file. | | AddNewStyle(String, String, String) | [NOT YET FULLY IMPLEMENTED]
Create a new style for this log file. | | AddNewStyle(String, String, String, Boolean) | [NOT YET FULLY IMPLEMENTED]
Create a new style for this log file. | | AddNewStyle(String, String, String, Boolean, Boolean) | [NOT YET FULLY IMPLEMENTED]
Create a new style for this log file. | | AddNonError | Adds a non-error line to the current log file. | | Close | Saves and closes the log file. | | DisableRowHeaders | Disable the additional information between the time/date and the log entry. | | Display | Displays the XHTML log file in Internet Explorer. | | EnableRowHeaders | Enables the additional information between the time/date and
the log entry and sets this information to the string which is passed in. | | Exists | Returns true if the log file currently exists. | | New | Deletes the current log file, closing first if necessary. | | Open | Opens or creates a log file. |
Properties
See Also
Version 4.10.0 ( last generated Monday, March 7, 2016 )
|