C# Класс SIL.Utils.Logger

Logs stuff to a file created in c:\Documents and Settings\Username\Local Settings\Temp\Companyname\Productname\Log.txt
This class also has a rudimentary implementation of IStream. The only really implemented method is IStream.Write, the other methods of this interface are no-ops or throw a NotImplementedException.
Наследование: IFWDisposable, IStream
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
m_out System.CodeDom.Compiler.IndentedTextWriter

Private Properties

Свойство Тип Описание
ConvertByteToChar char
Dispose void
GetLogText string
InitializeTextWriter void
Logger System
WriteEventInternal void

Открытые методы

Метод Описание
CheckDisposed ( ) : void

Check to see if the object has been disposed. All public Properties and Methods should call this before doing anything else.

Clone ( IStream &ppstm ) : void

Creates a new stream object with its own seek pointer that references the same bytes as the original stream.

Commit ( int grfCommitFlags ) : void

Ensures that any changes made to a stream object that is open in transacted mode are reflected in the parent storage.

CopyTo ( IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten ) : void

Copies a specified number of bytes from the current seek pointer in the stream to the current seek pointer in another stream.

Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Must not be virtual.

Init ( string projectName ) : void

Creates the logger. The logging functions can't be used until this method is called.

LockRegion ( long libOffset, long cb, int dwLockType ) : void

Restricts access to a specified range of bytes in the stream.

Read ( byte pv, int cb, IntPtr pcbRead ) : void

Reads a specified number of bytes from the stream object into memory starting at the current seek pointer.

Revert ( ) : void

Discards all changes that have been made to a transacted stream since the last M:System.Runtime.InteropServices.ComTypes.IStream.Commit(System.Int32) call.

Seek ( long dlibMove, int dwOrigin, IntPtr plibNewPosition ) : void

Changes the seek pointer to a new location relative to the beginning of the stream, to the end of the stream, or to the current seek pointer.

SetSize ( long libNewSize ) : void

Changes the size of the stream object.

ShutDown ( ) : void

Shut down the logger. The logging functions can't be used after this method is called.

Stat ( System &pstatstg, int grfStatFlag ) : void

Retrieves the structure for this stream.

UnlockRegion ( long libOffset, long cb, int dwLockType ) : void

Removes the access restriction on a range of bytes previously restricted with the method.

Write ( byte pv, int cb, IntPtr pcbWritten ) : void

Writes a specified number of bytes into the stream object starting at the current seek pointer.

WriteError ( Exception e ) : void

Writes an exception and its stack trace to the log. This method will do nothing if Init() is not called first.

WriteError ( string msg, Exception e ) : void

Writes msg and an exception and its stack trace to the log. This method will do nothing if Init() is not called first.

WriteEvent ( string message ) : void

Writes an event to the logger. This method will do nothing if Init() is not called first.

Приватные методы

Метод Описание
ConvertByteToChar ( byte b ) : char

Converts the byte to char.

Dispose ( bool disposing ) : void
GetLogText ( ) : string

Gets the log text.

InitializeTextWriter ( ) : void

Initializes (or reinitializes) the text writer.

Logger ( string logPrefix ) : System

Initializes a new instance of the Logger class.

WriteEventInternal ( string message ) : void

Writes the event to the logger.

Описание методов

CheckDisposed() публичный Метод

Check to see if the object has been disposed. All public Properties and Methods should call this before doing anything else.
public CheckDisposed ( ) : void
Результат void

Clone() публичный Метод

Creates a new stream object with its own seek pointer that references the same bytes as the original stream.
public Clone ( IStream &ppstm ) : void
ppstm IStream When this method returns, contains the new stream object. /// This parameter is passed uninitialized.
Результат void

Commit() публичный Метод

Ensures that any changes made to a stream object that is open in transacted mode are reflected in the parent storage.
public Commit ( int grfCommitFlags ) : void
grfCommitFlags int A value that controls how the changes for the stream /// object are committed.
Результат void

CopyTo() публичный Метод

Copies a specified number of bytes from the current seek pointer in the stream to the current seek pointer in another stream.
public CopyTo ( IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten ) : void
pstm IStream A reference to the destination stream.
cb long The number of bytes to copy from the source stream.
pcbRead System.IntPtr On successful return, contains the actual number of bytes /// read from the source.
pcbWritten System.IntPtr On successful return, contains the actual number of bytes /// written to the destination.
Результат void

Dispose() публичный Метод

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Must not be virtual.
public Dispose ( ) : void
Результат void

Init() публичный статический Метод

Creates the logger. The logging functions can't be used until this method is called.
public static Init ( string projectName ) : void
projectName string Name of the project that can be used (and certainly will /// be) to generate a unique log file name.
Результат void

LockRegion() публичный Метод

Restricts access to a specified range of bytes in the stream.
public LockRegion ( long libOffset, long cb, int dwLockType ) : void
libOffset long The byte offset for the beginning of the range.
cb long The length of the range, in bytes, to restrict.
dwLockType int The requested restrictions on accessing the range.
Результат void

Read() публичный Метод

Reads a specified number of bytes from the stream object into memory starting at the current seek pointer.
public Read ( byte pv, int cb, IntPtr pcbRead ) : void
pv byte When this method returns, contains the data read from the stream. /// This parameter is passed uninitialized.
cb int The number of bytes to read from the stream object.
pcbRead System.IntPtr A pointer to a ULONG variable that receives the actual number /// of bytes read from the stream object.
Результат void

Revert() публичный Метод

Discards all changes that have been made to a transacted stream since the last M:System.Runtime.InteropServices.ComTypes.IStream.Commit(System.Int32) call.
public Revert ( ) : void
Результат void

Seek() публичный Метод

Changes the seek pointer to a new location relative to the beginning of the stream, to the end of the stream, or to the current seek pointer.
public Seek ( long dlibMove, int dwOrigin, IntPtr plibNewPosition ) : void
dlibMove long The displacement to add to dwOrigin.
dwOrigin int The origin of the seek. The origin can be the beginning of /// the file, the current seek pointer, or the end of the file.
plibNewPosition System.IntPtr On successful return, contains the offset of the seek /// pointer from the beginning of the stream.
Результат void

SetSize() публичный Метод

Changes the size of the stream object.
public SetSize ( long libNewSize ) : void
libNewSize long The new size of the stream as a number of bytes.
Результат void

ShutDown() публичный статический Метод

Shut down the logger. The logging functions can't be used after this method is called.
public static ShutDown ( ) : void
Результат void

Stat() публичный Метод

Retrieves the structure for this stream.
public Stat ( System &pstatstg, int grfStatFlag ) : void
pstatstg System When this method returns, contains a STATSTG structure that /// describes this stream object. This parameter is passed uninitialized.
grfStatFlag int Members in the STATSTG structure that this method does not /// return, thus saving some memory allocation operations.
Результат void

UnlockRegion() публичный Метод

Removes the access restriction on a range of bytes previously restricted with the method.
public UnlockRegion ( long libOffset, long cb, int dwLockType ) : void
libOffset long The byte offset for the beginning of the range.
cb long The length, in bytes, of the range to restrict.
dwLockType int The access restrictions previously placed on the range.
Результат void

Write() публичный Метод

Writes a specified number of bytes into the stream object starting at the current seek pointer.
public Write ( byte pv, int cb, IntPtr pcbWritten ) : void
pv byte The buffer to write this stream to.
cb int The number of bytes to write to the stream.
pcbWritten System.IntPtr On successful return, contains the actual number of bytes /// written to the stream object. If the caller sets this pointer to null, this method /// does not provide the actual number of bytes written.
Результат void

WriteError() публичный статический Метод

Writes an exception and its stack trace to the log. This method will do nothing if Init() is not called first.
public static WriteError ( Exception e ) : void
e System.Exception
Результат void

WriteError() публичный статический Метод

Writes msg and an exception and its stack trace to the log. This method will do nothing if Init() is not called first.
public static WriteError ( string msg, Exception e ) : void
msg string
e System.Exception
Результат void

WriteEvent() публичный статический Метод

Writes an event to the logger. This method will do nothing if Init() is not called first.
public static WriteEvent ( string message ) : void
message string
Результат void

Описание свойств

m_out защищенное свойство

protected IndentedTextWriter,System.CodeDom.Compiler m_out
Результат System.CodeDom.Compiler.IndentedTextWriter