<?php
/*
GESTIN - Sistema de Gestion de Incidencias
Copyright (C) 2007 Mathias Rodriguez, Diego Martorell, Matias Bisay
This file is part of GESTIN.
GESTIN is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GESTIN is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GESTIN. If not, see <http://www.gnu.org/licenses/>.
*/
class Transaccion {
private $mensaje;
private $marcaDeTiempo;
private $archivo;
private $nombreArchivo;
public function __construct($men, $arc) {
date_default_timezone_set('America/Montevideo');
self::setMensaje($men);
self::setMarcaDeTiempo(date("D d/m/y H:i:s" , time()));
self::setArchivo($arc);
}
public function __destruct() {
self::cerrarArchivo();
}
public function setMensaje($men) { $this->mensaje = $men; }
private function setMarcaDeTiempo($mar) { $this->marcaDeTiempo = $mar; }
private function setArchivo($arc) {
$this->nombreArchivo = $arc;
$this->archivo = fopen($arc,"a+");
if($this->archivo == null) {
echo "No se pudo abrir el archivo";
}
}
public function cerrarArchivo() {
fclose($this->archivo);
}
public function grabarLog() {
$trace = "[" . $this->marcaDeTiempo . "] " . $this->mensaje;
fprintf($this->archivo, "%s\n" , $trace);
}
public function verLog() {
$log = file($this->$nombreArchivo);
return $log;
}
}
?>