<?php

class Logger
{
  public function __construct( $filename='logs', $path='/logs/' )
  {
    $this->path     = ($path) ? $path : "/";
    $this->path     = dirname( __FILE__ ) . $this->path;

    $this->filename = ($filename) ? $filename : "log";
    $this->date     = date("Y-m-d H:i:s");
    $this->ip       = ($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 0;
  }

  public function info($text)
  {
    $this->date     = date("Y-m-d H:i:s");
    $append = FILE_APPEND;
    $texto    = '[INFO] '. $this->date . ': ' ./* $this->ip . ') ' .*/ $text . PHP_EOL;
    $fileLog = $this->path . $this->filename . ".log";
    $result = file_put_contents($fileLog, $texto, $append);
    if( $result === 0 || $result === false ) {
      return false;
    }
    return true;
  }
}