<?php

/**
 * Module qui logs les commandes envoyés
 * 
 * @author Olivier Arteau
 */

class Logs implements Module {
	private $res;
	
	public function __construct() {
		$this->res = fopen('logs/log.txt', 'a');
	}
	
    public function executerCommande(array $param, StatusObject $status) {
    	$log = 'Commande : ' . $param['cmd'] . "\n";
    	
    	foreach ($param as $key=>$value) {
    		$log .= "\t" . $key . '=' . $value . "\n";
    	}
    	
    	$log .= "\tStatus : " . $status->toString() . "\n-------------------\n";
    	fwrite($this->res, $log);
    }
    
    public function onStatusChange(array $param, StatusObject $status) {
    	
    }
    
    public function getCommandesEnregistre() {
    	return array(ALL_COMMANDE);
    }
    
    public function finalize(array $param, StatusObject $status) {
   		
   	}
}

PAFServer::getInstance()->enregistrerModule(new Logs());
?>