The CodeSite Logging System gives developers deeper insight into how their code is executing, which enables them to locate problems more quickly and ensure their application is running correctly. CodeSite's logging classes let developers capture all kinds of information while their code executes and then send that information to a live display or to a log file. Furthermore, both styles of logging, live logging and file logging, can be performed locally or remotely (via TCP, UDP, or HTTP).
A key element to CodeSite's effectiveness is that unlike message boxes and inspecting variables on breakpoints, CodeSite messages are not transient. The resulting log of messages provides valuable information for locating problem areas in your code. In addition, sending CodeSite messages does not interrupt the flow of your application as happens when message boxes and breakpoints are used. As a result, CodeSite is much more effective in situations where user interactions (eg. focus changes) and painting issues need to be tracked.
CodeSite also addresses several shortcomings with traditional logging/tracing solutions. For example, CodeSite allows logging complex data structures and is not limited to simple strings. CodeSite also provides more control over what gets logged and when. Instead of relying on arbitrary logging levels, separate loggers are used to categorize CodeSite messages. CodeSite also gives developers more flexibility in managing their logging information such as enabling multiple applications (or multiple instances of the same application) to send logging information to the same log file. In addition, the CodeSite viewers, which are designed specifically for analyzing CodeSite logging messages, provide extensive, easy-to-use tools for analysis.
There are three core components to the CodeSite Logging System:
- The CodeSite Logging Classes
- The CodeSite Dispatcher
- The CodeSite Viewers
The CodeSite Logging Classes
The primary logging class that developers use is T|CodeSiteLogger. (TCodeSiteLogger in Delphi, CodeSiteLogger in .NET.) However, in most cases, developers do not have to manually construct an instance of the T|CodeSiteLogger class. Instead, the CodeSite logger instance can be used immediately. In the Delphi, CodeSite is a global instance of the TCodeSiteLogger class. In .NET, CodeSite is a static class that uses an internal CodeSiteLoggerinstance.
Logging information simply involves calling methods of the T|CodeSiteLogger class. Most often, the overloaded Send method will be used. In its simplest form, a simple string message is sent. Other forms include sending numeric data types, dates and times, objects, collections, bitmaps, and much more.
The CodeSite Dispatcher
The primary logging method in T|CodeSiteLogger is named Send because it more accurately describes what happens to the information being logged. In particular, T|CodeSiteLogger instances send logging information to the CodeSite Dispatcher application, which runs in the background and is responsible for dispatching CodeSite logging messages to their final destination.
There are two basic destinations for CodeSite messages: a CodeSite Live Viewer (see below); and a CodeSite Log File. However, these two destination types may reside either locally or on a remote machine. Plus, there are several ways for the CodeSite Dispatcher to transport messages to their final destination. The location of the viewer or log file as well as the transport details to be used by the Dispatcher is contained in a T|CodeSiteDestinationinstance, which the CodeSite Dispatcher receives from each T|CodeSiteLogger instance.
In addition to its dispatching responsibilities, the CodeSite Dispatcher also allows for dynamic blocking of selected CodeSite message types and even selected categories. Furthermore, the Dispatcher manages a list of symbolic paths that can be referenced by T|CodeSiteDestination objects.
The CodeSite Viewers
The CodeSite Logging System comes with two viewers: the CodeSite Live Viewer and the CodeSite File Viewer. Developers will most often use the CodeSite Live Viewer, which is updated immediately as new CodeSite logging messages are received from the CodeSite Dispatcher. As a result, the Live Viewer is required for live logging.
During file logging, the CodeSite Dispatcher writes the messages it receives directly to a CodeSite Log File. However, even with file logging, one must eventually view the file contents. Although log files can be loaded into the Live Viewer, this is not always practical especially if the Live Viewer is currently being updated during a live logging session. In addition, there are features in the Live Viewer, such as the Scratch Pad, that are only applicable for live logging. As a result, the CodeSite File Viewer is associated with the CodeSite Log File extension (*.csl).
Both viewers include a wide variety of inspectors and other tools specifically designed for analyzing CodeSite messages. For example, the Message Organizer can analyze the logging messages and automatically create appropriate views to isolate messages of the same application, category, thread name, etc.