1.0.4 • Published 5 years ago

@jesusmatiz/reportlog v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

ReportLog

Versión en Español

ReportLog captura el error y lo almacena en un archivo de texto plano ".txt" o tambien permite almacenarlo en una tabla de la base de datos, según la configuración.

Configurando el tipo de almacenamiento

Para configurar el tipo de almacenamiento, debe modificar la siguiente linea en el archivo Connection.php.

Almacenamiento en .txt

Si desea almacenar los datos en un archivo de texto ".txt" debe establecer la siguiente variable en false.

Al establecer el almacenamiento de log en el archivo .txt, se creara un directorio con el nombre de storage y dentro de este se crearan archivos con el nombre log_2019-01-21.txt, donde la fecha cambia según el dia del error, para asi poder identificarlo mucho mas rapido.

Rutade almacenamiento del log en .txt

El almacenamiento de los logs se encuentran en el directorio storage, el cual sera creado la primera vez que se genere un error, siempre y cuando la variable $useDB este en false;

Almacenamiento en base de datos

Para almacenar los datos a una tabla de la base de datos debera ejecutar el script create_report_logs_table.sql en su base de datos.

Al importar el archivo create_report_logs_table.sql, se creara una tabla con los campos necesarios para el almacenamiento de los errores.

Si desea almacenar los datos en una tabla de la base datos debe establecer la siguiente variable en true.

Ademas debera configurar las credenciales para la conexión de la base de datos en las siguientes variables.

La tabla report_logs tiene los siguientes campos:

  • id (ID del error)
  • type_error (Tipo de error)
  • message (Mensaje de error)
  • trace (Traza de propagación del error)
  • file (Archivo final de propagación del error)
  • line (Linea de codigo cercano al error)

Importación de la conexión

Importe el archivo de conexión

Cree una variable privada para el ReportLog

Inicialize la variable del reportLog con una nueva instancia.

Para guardar el log debera establecer en un try-catch

Tipos de logs de errores

Podrá usar los siguientes logs de errores, según la necesidad.

Intalación por NPM

Para instalar como paquete desde npm ejecute el siguiente comando.

Requerimientos

  • PHP >= 5.6

Version in English

ReportLog captures the error and stores it in a plain text file ".txt " or also allows it to be stored in a database table, depending on the configuration.

Configuring the storage Type

To configure the storage type, you must modify the following line in the Connection.php file.

.txt storage

If you want to store the data in a text file ".txt" You must set the following variable to false.

When you set log storage to the file .txt, will create a directory with the name of storage and within this will create files named log_2019-01-21.txt, where the date changes according to the day of the error, so you can identify much faster.

Log storage path in .txt

Log storage is located in the storage directory, which will be created the first time an error is generated, as long as the variable $useDB is set to false;

Database storage

To store the data to a database table you must run the create_report_logs_table.sql script in your database.

When you import the create_report_logs_table.sql file, you create a table with the required fields for error storage.

If you want to store the data in a table in the database, you must set the following variable to true.

You must also configure the credentials for the database connection in the following variables.

The report_logs table has the following fields:

##Importing the connection

Import the Connection file

Create a private variable for the ReportLog

private $reportLog;

Initialize the REPORTLOG variable with a new instance.

To save the log you must set in a try-catch

Types of error logs

You can use the following error logs, as needed.

Installation by NPM

To install as a package from NPM run the following command.

npm I @jesusmatiz/reportlog

Requirements

  • PHP >= 5.6
1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago