<?php  // vim:set et ts=4 sw=4 sts=4:
# Copyright (C) 2003-2014 hipplay Inc.
#
# This is UNPUBLISHED PROPRIETARY SOURCE CODE OF hipplay Inc.
# The copyright notice above does not evidence any actual or intended
# publication of such source code. The contents of this file may not
# be disclosed to third parties, copied or duplicated in any form, in
# whole or in part, without the prior written permission of
# hipplay Inc.
#
namespace HipPlayConnect;


//TODO: move this to global later..
DEFINE('HIPSERV_LOG_FILE', '/var/log/axentra/hipserv.log');

class AxDebug
{
	
	// Singleton
	private static $instance = null;
	


    public function saveEntries($entries)
    {        
        if (!$handle = fopen(HIPSERV_LOG_FILE, 'a')) {
            error_log( "Cannot open file (".HIPSERV_LOG_FILE.")");
            return false;
        }
        
        $logentry = '';
        foreach($entries as $entry)
            $logentry .= date(DATE_RFC822) . " - [".$entry['level']."] ".$entry['value']."\n";
        
        if (fwrite($handle, $logentry) === FALSE) {
           error_log( "Cannot write to file (".HIPSERV_LOG_FILE.")");
           return false;
        }
        
        fclose($handle);
        return true;
    }
	
	public function getXML()
	{

		return <<<EOUSER
<?xml version="1.0"?>
<debug>
<entry level="WARN">message</entry>
</debug>
EOUSER
;

	}
	
	//
	// Singleton pattern
	//
	public static function getInstance()
	{
		if ( is_null( self::$instance ) )
		    self::$instance = new AxDebug();
		return self::$instance;
	}	
}
?>