Logger for engine
composer require giolaza/logger
define('GIOLAZA_SHOW_ERRORS', false);
define('GIOLAZA_SAVE_ERRORS', true);
define('GIOLAZA_LOGS_FOLDER', __DIR__ . '/../___productionLogs');
Constant GIOLAZA_SHOW_ERRORS
defines display detail information about error or not. if value is false
engine will print something went wrong
.
Constant GIOLAZA_SAVE_ERRORS
defines save detail information about error in files or not.
Constant GIOLAZA_LOGS_FOLDER
defines log folder link. It's recommended to use folder outside root folder or add .htaccess
to restrict direct access from www
GioLaza\Logger\Log::logError(text: 'ANY TEXT',filename: 'filename.log', engineForceStop: true, dispalyErrors: true)
engineForceStop
- means need or not use die
dispalyErrors
- is method variable, if constant allows show errors, method will print it.
GioLaza\Logger\Log::logError(text: 'DB connection error ',filename: 'db.log')
This code will print your text,save text to file and force stop php execution
GioLaza\Logger\Log::logError(text: 'DB connection error ',filename: 'db.log',engineForceStop: true, dispalyErrors: false)
This code will NOT print your text,save text in file and force stop php execution
GioLaza\Logger\Log::logError(text: 'User id: 12 ',filename: 'db.log',engineForceStop: true, dispalyErrors: false)
This code will NOT print your text or force stop php execution, just save text in file