log_base Class Reference

Provides an abstract base for logging mechanisms. More...

#include <log_base.h>

Inheritance diagram for log_base:

Inheritance graph
[legend]
Collaboration diagram for log_base:

Collaboration graph
[legend]
List of all members.

Public Types

enum  KNOWN_FILTERS { ALWAYS_PRINT = common::ALWAYS_PRINT, NEVER_PRINT = common::NEVER_PRINT }
 Filter values are used to choose what kinds of logged items to allow. More...
enum  line_ending { LF_AT_END = -15, CRLF_AT_END, NO_ENDING }
 Line endings specify how the endings of logged lines are handled. More...

Public Member Functions

 log_base ()
 Constructor initializes the log base members.
 log_base (const log_base &to_copy)
 copy constructor.
virtual ~log_base ()
 Virtual destructor deallocates everything.
log_baseoperator= (const log_base &to_copy)
 assignment operator.
virtual void add_filter (int new_filter)
 Adds a member to the filter set.
virtual void remove_filter (int old_filter)
 Removes a member from the filter set.
virtual bool member (int filter_to_check)
 Returns true if the "filter_to_check" is a member of the filter set.
virtual void clear_filters ()
 Resets the filter set to be empty.
virtual int_set filter_set ()
 Returns the current filter set's contents.
virtual line_ending eol ()
 observes how line endings are to be printed.
virtual void eol (line_ending to_set)
 modifies how line endings are to be printed.
virtual istring get_ending ()
 returns a string for the current ending.
virtual void get_ending (istring &to_end)
 appends a string for the current ending to "to_end".
virtual outcome log (const istring &info, int filter=ALWAYS_PRINT)=0
 writes the information in "info" to the log using the "filter" value.
outcome log (const char *info, int filter=ALWAYS_PRINT)
 synonym for log that provides char * support.
log_baseoperator<< (const istring &info)
 synonym for log that mimics a stream interface and takes an istring.
log_baseoperator<< (const char *info)
 synonym for log that mimics a stream interface and takes char *.
void stuff_filter_set (const int_set &new_set)
 this non-virtual method simply accesses the internal list.

Static Public Member Functions

static const char * string_for_ending (line_ending ending)
 returns the string form for the "ending" value.
static line_ending pick_ending_for_platform ()
 provides the appropriate ending on the current OS platform.
static const char * platform_ending ()
 provides the characters that make up this platform's line ending.

Detailed Description

Provides an abstract base for logging mechanisms.

This assists greatly in generating diagnostic entries polymorphically and in enabling different logging mechanisms to be plugged in easily. Note that all of the functions are defined virtually which enables overriding pretty much all of the base functionality. Use this wisely, if ever.

Definition at line 30 of file log_base.h.


Member Enumeration Documentation

enum log_base::KNOWN_FILTERS

Filter values are used to choose what kinds of logged items to allow.

the first service offered by the base class is filtering. filters provide a way to reconfigure what is logged; anything in the current filter set WILL be logged when that filter is used in the log() method. anything not in the set (except ALWAYS_PRINT) will not be logged. the set of filters can be modified except that ALWAYS_PRINT will always be included in the set and NEVER_PRINT will never be included.

Enumerator:
ALWAYS_PRINT  Always allows the logging.
NEVER_PRINT  Never allows the logging.

Definition at line 48 of file log_base.h.

enum log_base::line_ending

Line endings specify how the endings of logged lines are handled.

the second service offered by this base class is the notion of line endings. on ms-dos, every line in a file has a carriage return (CR) and a line feed (LF) appended to the line. on unix, only a line feed (LF) character is used. thus, if you want the logging entries to be logged on separate lines, you can use LF_AT_END or CRLF_AT_END to cause that. if you want to make up a logging line out of multiple parts, then use NO_ENDING before printing the first part (saving the original setting for eol() temporarily), print every part but the last part, change the ending back to its original value, and print the final part. NOTE: it is up to the derived classes to implement the use of the appropriate line ending; they are the implementors of the log() method and so must do whatever is right for the current ending (the get_ending() method can help).

Enumerator:
LF_AT_END  Unix standard is LF_AT_END ("\n").
CRLF_AT_END  DOS standard is CRLF_AT_END ("\r\n").
NO_ENDING  No additional characters will be added to line endings.

Definition at line 88 of file log_base.h.


Constructor & Destructor Documentation

log_base::log_base (  ) 

Constructor initializes the log base members.

Definition at line 24 of file log_base.cpp.

log_base::log_base ( const log_base to_copy  ) 

copy constructor.

Definition at line 31 of file log_base.cpp.

log_base::~log_base (  )  [virtual]

Virtual destructor deallocates everything.

Definition at line 38 of file log_base.cpp.

References WHACK().


Member Function Documentation

log_base & log_base::operator= ( const log_base to_copy  ) 

assignment operator.

Definition at line 44 of file log_base.cpp.

References _ending, and _filter_set.

void log_base::add_filter ( int  new_filter  )  [virtual]

Adds a member to the filter set.

The filter set is used to check all extended filter values passed to log and print. if the special filters of ALWAYS_PRINT or NEVER_PRINT are added, then either everything will be logged or nothing will be.

Reimplemented in combo_logger, and locked_logger.

Definition at line 67 of file log_base.cpp.

References basis::set< contents >::add().

Referenced by combo_logger::add_filter().

void log_base::remove_filter ( int  old_filter  )  [virtual]

Removes a member from the filter set.

Reimplemented in combo_logger, and locked_logger.

Definition at line 61 of file log_base.cpp.

References basis::set< contents >::remove().

Referenced by combo_logger::remove_filter().

bool log_base::member ( int  filter_to_check  )  [virtual]

Returns true if the "filter_to_check" is a member of the filter set.

If "filter_to_check" is ALWAYS_PRINT, this always returns true. If the value is NEVER_PRINT, false is always returned.

Reimplemented in locked_logger.

Definition at line 79 of file log_base.cpp.

References ALWAYS_PRINT, basis::set< contents >::member(), and NEVER_PRINT.

Referenced by file_logger::format_bytes(), file_logger::log(), console_logger::log(), wx_debugging_base::log(), debugging_base::log(), and file_logger::log_bytes().

void log_base::clear_filters (  )  [virtual]

Resets the filter set to be empty.

Reimplemented in combo_logger, and locked_logger.

Definition at line 55 of file log_base.cpp.

References basis::set< contents >::clear().

Referenced by combo_logger::clear_filters().

int_set log_base::filter_set (  )  [virtual]

Returns the current filter set's contents.

Reimplemented in locked_logger.

Definition at line 88 of file log_base.cpp.

log_base::line_ending log_base::eol (  )  [virtual]

observes how line endings are to be printed.

Reimplemented in locked_logger.

Definition at line 94 of file log_base.cpp.

Referenced by debugger::debugger(), combo_logger::eol(), file_logger::log(), console_logger::log(), wx_debugging_base::log(), wx_debugger::log(), debugger::log(), debugging_base::log(), wx_debugging_base::log_ending(), debugging_base::log_ending(), nechung_oracle::pick_random(), and service_root::remove().

void log_base::eol ( line_ending  to_set  )  [virtual]

modifies how line endings are to be printed.

Reimplemented in combo_logger, and locked_logger.

Definition at line 100 of file log_base.cpp.

References CRLF_AT_END, LF_AT_END, and NO_ENDING.

istring log_base::get_ending (  )  [virtual]

returns a string for the current ending.

Reimplemented in locked_logger.

Definition at line 138 of file log_base.cpp.

References string_for_ending().

Referenced by get_ending(), file_logger::log(), console_logger::log(), wx_debugging_base::log(), and debugging_base::log().

void log_base::get_ending ( istring to_end  )  [virtual]

appends a string for the current ending to "to_end".

Reimplemented in locked_logger.

Definition at line 140 of file log_base.cpp.

References get_ending().

virtual outcome log_base::log ( const istring info,
int  filter = ALWAYS_PRINT 
) [pure virtual]

writes the information in "info" to the log using the "filter" value.

the "filter" value must be checked to see if it is in the current set of allowed filters (using member()). this function _must_ be provided by derived classes and it _must_ check the filter before printing if it wants to be in compliance with log_base protocols. it also must implement the line_ending appropriately. the return value will often be a member of the common outcomes, but derived classes may see fit to return other things. note that an object derived from log_base should be thread-safe and protect its own member attributes through synchronization.

Implemented in debugging_base, debugger, wx_debugger, wx_debugging_base, console_logger, file_logger, combo_logger, locked_logger, and null_logger.

Referenced by guards::alert_message(), infoton::check_classifier(), nodes::path::generate_path(), service_root::install(), service_root::instruct(), application_shell::log(), log(), service_root::log_event(), version_ini::one_stop_version_stamp(), operator<<(), wx_debugging_base::print(), debugger::print(), debugging_base::print(), query_handler::print_row(), service_root::remove(), query_handler::show_this_row(), service_root::standalone(), common_database_support::syb_err_handler(), common_database_support::syb_msg_handler(), and version_ini::write_assembly().

outcome log_base::log ( const char *  info,
int  filter = ALWAYS_PRINT 
)

synonym for log that provides char * support.

Definition at line 52 of file log_base.cpp.

References log().

log_base& log_base::operator<< ( const istring info  )  [inline]

synonym for log that mimics a stream interface and takes an istring.

Definition at line 120 of file log_base.h.

References log().

log_base& log_base::operator<< ( const char *  info  )  [inline]

synonym for log that mimics a stream interface and takes char *.

Definition at line 122 of file log_base.h.

References log().

const char * log_base::string_for_ending ( line_ending  ending  )  [static]

returns the string form for the "ending" value.

Definition at line 121 of file log_base.cpp.

References CRLF_AT_END, LF_AT_END, and NO_ENDING.

Referenced by get_ending(), and platform_ending().

log_base::line_ending log_base::pick_ending_for_platform (  )  [static]

provides the appropriate ending on the current OS platform.

Definition at line 107 of file log_base.cpp.

References CRLF_AT_END, and LF_AT_END.

Referenced by nechung_oracle::pick_random(), platform_ending(), and parser_bits::translate_CR_for_platform().

const char * log_base::platform_ending (  )  [static]

provides the characters that make up this platform's line ending.

Definition at line 135 of file log_base.cpp.

References pick_ending_for_platform(), and string_for_ending().

Referenced by xml_generator::add_content(), guards::alert_message(), cromp_common::chew_hostname(), tcpip_stack::enumerate_adapters(), xml_generator::generate(), process_manager::launch_now(), main(), nechung_oracle::pick_random(), database_login_info::replace_value(), ini_parser::restate(), smtp_client::send_email(), smtp_client::setup_session(), mailbox::show(), buffer_manager::show_buffers(), connection_table::show_connections(), zing_table::show_events(), post_office::show_mail(), name_cache::show_names(), post_office::show_routes(), string_manipulation::split_lines(), tokenizer::text_form(), filename_list::text_form(), directory_tree::text_form(), command_line::text_form(), nodes::symbol_tree::text_form(), string_table::text_form(), memory_limiter::text_form(), bit_vector::text_form(), socket_minder::text_form(), grid_processor::write_bogus_row(), grid_processor::write_fields_for_row(), critical_events::write_to_critical_events(), and scheduler::~scheduler().

void log_base::stuff_filter_set ( const int_set new_set  ) 

this non-virtual method simply accesses the internal list.

it allows derived objects to change the filter list without confusion about which object implements the call.

Definition at line 73 of file log_base.cpp.


The documentation for this class was generated from the following files:
Generated on Wed Jul 23 04:35:11 2008 for HOOPLE Libraries by  doxygen 1.5.1