Location: PHPKode > projects > KvCMS Content Management System > kvframework/kvframework/logger/log_types/kvframework_email_logger.class.php
<?php

class kvframework_email_logger extends kvframework_logger
{
    protected $recipient;
    protected $sender;
    protected $subject;
    protected $mailbody;

    public function __construct(&$parent_logger_instance, $parent_application)
    {
        parent::__construct ($parent_logger_instance, $parent_application);
        $this->email_set_recipient ( kvframework_log::DEFAULT_EMAIL_RECIPIENT );
        $this->email_set_sender ( kvframework_log::DEFAULT_EMAIL_SENDER );
        $this->email_set_subject ( DEFAULT_EMAIL_SUBJECT );
        $this->type = "email";
    }

    public function email_set_recipient ( $recipient )
    {
        $this->recipient = $recipient;
        $this->needs_reset = TRUE;
    }

    public function email_set_sender ( $sender )
    {
        $this->sender = $sender;
        $this->needs_reset = TRUE;
    }

    public function email_set_subject ( $subject )
    {
        $this->subject = $subject;
        $this->needs_reset = TRUE;
    }

    public function type_specific_reset()
    {
    }

    public function type_specific_open()
    {
        unset ($this->mailbody);
        return ( TRUE );
    }

    public function type_specific_output_msg($entry)
    {
        $severity = $entry["MSG_SEVERITY"];
        $this->mailbody .=  str_pad($entry["MSG_TIME"], 36).str_pad($entry["MSG_CATEGORY"], 13).str_pad($this->syslog_levels[$severity], 13).$entry["MSG_MSG"]."\n";
    }

    public function type_specific_close()
    {
        if(!mail($this->recipient, $this->subject, $this->mailbody, $this->sender, "-hide@address.com"))
        {
            $msg = "EMAILING FAILED: to ".$this->recipient.", from ".$this->sender.", subject ".$this->subject.", body ".$this->mailbody;
            $this->write_logger_log($msg);
            return ( FALSE );
        }
        return ( TRUE );
    }

}
?>
Return current item: KvCMS Content Management System