I'm back on track with writing code for the NyMPH project. I started using the EventLogHelper class and quickly realized I had an opportunity to make things a bit easier to use it.
I started adding namespaces to the classes I've touched so far. Since they were all auto-generated, they are all at the same 'level'.
The namespace scheme I came up with is as follows: Root level namespace is NyMPH, second level namespace refers to the 'package' a class falls under (i.e. Patches, Persistence, etc.). For example, the fully qualified name for the Patch type would be NyMPH.Patches.Patch.
I added a 'generic' method to the ELH called WriteEvent(). This method looks at the instance that invoked it to see if it should write to a log file, write to the Event Log, or write to the Application Event Log. It tests the FileInfo object for null, followed by the EventLog object for the 'custom' log.
I then used preprocessor directives to create an instance of ELH using a log file (for debugging), or registered Event Log and Event Source names for the 'release' version (which will create the log and source values during installation).
This allows me to simply call the WriteEvent() method as needed without having to check for 'debug mode' each time.
For each class, then, I will use the fully qualified name for log files. Errors that happen in the FileSystem class, for example, would be written to the same directory as the executable as NyMPH.Persistence.FileSystem.Errors.log.
For writing to log files, I should probably implement something a bit more structured for writing errors than just dumping the Message onto a single line. I may create an XML file or something to do this.
I also need to start keeping track of individual classes as I write code for them. Specifically, I need to keep track of the following states:
untouched (generated code only)
in process (working on them)
on hold (have worked on them but waiting for something)
almost ready (can be tested but contains 'TODO' markers)
ready (can be tested fully)
Thursday, September 3, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment