Skip to Main Content
Prefactoring
book

Prefactoring

by Ken Pugh
September 2005
Intermediate to advanced content levelIntermediate to advanced
240 pages
6h 28m
English
O'Reilly Media, Inc.
Content preview from Prefactoring

15.5. Logging

On the EnvisionWare system, message logging occurs at the interfaces ("Plan Your Logging Strategy"). Since the implementations are simple, we made logging part of the implementation, instead of using a proxy. In particular, the classes containing logging calls are:

    class ClientMessageDispatcher implements MessageReceiver
        Message process_message(Message message_to_process)
    class ServerMessageDispatcher implements MessageReceiver
        Message process_message(message_to_process)

ClientMessageDispatcher logs all outgoing requests and returned responses. ServerMessageDispatcher logs all incoming requests and returned responses. The logs are created in a searchable format by adding a convert_to_keywords( ) method to each Message class and a encode_into_keywords( ) method to MessageEncoderDecoder—the convert_to_keywords( ) method creates attribute/value pairs (e.g., NumberPrintJobs=2) for each attribute. encode_into_keywords( ) adds attribute/value pairs for the base Message class attributes. The attribute/value pairs make it easier to search and filter logs for particular messages with particular values.

One potential addition is to create decode_from_keywords( ). You would use this method to decode each entry in a log. You could use the decoded entries to create a stream of messages that would duplicate a real or simulated stream. You could use this stream of messages for debugging and regression testing.

The ClientEnvironment and ServerEnvironment methods might also perform ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Understanding Unittest.Mock

Understanding Unittest.Mock

Mario Corchero
Java™ Performance

Java™ Performance

Charlie Hunt, Binu John

Publisher Resources

ISBN: 0596008740Supplemental ContentCatalog PageErrata