PHP code example of emiherber / lambdasi-logs

1. Go to this page and download the library: Download emiherber/lambdasi-logs library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

emiherber / lambdasi-logs example snippets



use Emiherber\LambdasiLogs\Logger;
use Emiherber\LambdasiLogs\LogLevel;

define('__DR__', $_SERVER['DOCUMENT_ROOT'].'/lambdasi-logs/');

define('TOKEN', 'token_bot');
define('CHATID', 'id_destinatario_mensajes');
define('TITULOSISTEMA', 'nombre_aplicación');

try {
  test();
  echo 'log generado <br>';

} catch (\Throwable $th) {
  echo 'error al generar el log <br>';
  throw $th;
}

function test() {
  try {

    $valores = [
      'clave' => 'valor',
      'clave2' => 'valor2'
    ];

    throw new Exception('prueba2');

  } catch (\Throwable $th) {
    $log = new Logger();
    $log->log(LogLevel::DEBUG, 'test', compact('th'));
    $log->log(LogLevel::ERROR, 'test', ['th' => new Error('Error')]);
    $log->log(LogLevel::WARNING, $th->getMessage(), ['th' => new Exception('Exception')]);
    $log->warning($th->getMessage(), ['th' => new Exception('Exception')]);
    $log->alert($th->getMessage());
  }
}