Knowledge Base / Appnel Solutions 

Last Modified
10 January 2007 @ 12am

MT::Log::Base

NAME

MT::Log::Base - a base class for creating application and task-specific activity log classes easier.

VERSION

0.14

SYNOPSIS

  # creating a subclass....

  package MT::Log::Example;
  use base 'MT::Log::Base';
  MT::Log::Example->install;
  sub class_label { 'Example' }
  1;

  # to use it to log message an application...

  use MT::Log::Example;
  MT::Log::Example->warning('warning! will rogers, danger!');
  MT::Log::Example->log_error('ACK!','this is metadata');

DESCRIPTION

MT::Log::Base is a base class for creating application and task-specific activity logging classes easier. The class itself is a subclass of MT::Log that provides additional functionality and common operations missing from MT::Log that most logging classes will need to perform.

METHODS

NOTE: This section only details methods that are provided or altered by MT::Log::Base as a subclass of MT::Log. See the MT::Log documentation for more details.

  • MT::Log::Base->install

    Calls MT::Log->add_class on itself to register itself with the system. All subclasses should call this method when initially loaded.

  • MT::Log::Base->new([%params||\%params])

    A more functional constructor that handles a lot of common initialization automatically.

    • Dereferences parameters represented as a HASH reference to be passed through to the MT::Log constructor
    • Automatically sets the blog_id, ip and author_id columns if possible
    • Defaults to the log level to info if one has not been set
  • $log->class_label

    Forces any subclasses of MT::Log::Base to overload this method.

  • $log->key

    Returns a lowercase representation of the value returned by class_label.

  • $log->metadata([$data])

    Gets/sets the metadata column. Automatically truncates the metadata string if it exceeds 255 characters.

  • $log->description

    Returns the value of metadata as an HTML encoded string and wrapped in pre tags.

Logging Methods

MT::Log::Base provides a group of class methods that make the process of creating a activity log object, setting all the necessary column values and saving it possible in one statement.

Each level has its own method and take a required message string and an optional metadata string.

Available methods are as follows:

  • MT::Log::Base->log($message,[$metadata])

    Posts a (info) message in the activity log

  • MT::Log::Base->diag($message,[$metadata])

    Posts a diagnostic message in the activity log

  • MT::Log::Base->warnings($message,[$metadata])

    Posts a warning message in the activity log

  • MT::Log::Base->security($message,[$metadata])

    Posts a security message in the activity log

  • MT::Log::Base->error_log($message,[$metadata])

    Posts a error message in the activity log

AUTHOR & COPYRIGHT

Copyright 2005-2007 Appnel Internet Solutions, LLC, info@appnel.com. All Rights Reserved. This code cannot be redistributed without permission of the author.


 

Submit Feedback on This Article

Your comments on how we can improve this article are appreciated. Please do not use the feedback form to submit support requests or question. We will not respond to or publish such queries submitted through this form.

Back to Home