Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Log management

besstiolle edited this page Feb 20, 2015 · 4 revisions

The Orm framework owns a minimalist Log system.

The console

To see all the messages generated by the different modules you have to go inside the admin panel of the module Orm.

console

The first Dropdown will allow you to reduce/increase the number of messages generated. It does not influence the messages generated in the past.

In a production environment you should let the setting at INFO or WARN but not at DEBUG.

All the messages generated are written into a temp file : ./tmp/cache/orm.log and you can clear the console by clicking on the second button Clean Log.

You don't need to refresh the page to see the new messages. It's automatic :)

Use of the Log system inside your own modules

You only need to know 4 functions :

OrmTRACE::debug('I am here !');
OrmTRACE::info('Everything was okay');
OrmTRACE::warn('Wrong parameter detected');
OrmTRACE::error('Boom... Head shoot !');

There is also another level between info and warn : OrmTRACE::sql('select * from table'); but its logically reserved to the inner system of ORM since you don't have to code the MySQL queries anymore ;)

if the level of debug selected in the admin panel of the module Orm is high enough, your message will be add to the others

Example : if my level of debug selected is WARN

OrmTRACE::debug('I am here !');
OrmTRACE::info('Everything was okay');
OrmTRACE::warn('Wrong parameter detected');
OrmTRACE::error('Boom... Head shoot !');

Will produce in the console :

yyyy-mm-dd hh:mm:ss - [WARN] - Wrong parameter detected
yyyy-mm-dd hh:mm:ss - [ERROR] - Boom... Head shoot !

Debug the Mysql Stack Trace

Since the version 0.3.2 ORM will persist the last Queries in a custom stack. You can print these queries anytime you need (for debug)

//Display the lastest 5 queries for your debug
var_dump(OrmDb::getBufferQueries());

You can also set a different size for this stack (5 by default) simply coding OrmDb::setBufferLength(20); before executing your own code.