DooPHP comes with its own profiler and logging tool by default. The class that handle this in the framework is DooLog (dooframework/app/logging/DooLog.php)
There are a few methods in this file where you can use for profiling and logging queries or important message in your application. You can log a message by calling:
1.
Doo::logger()->log(
'Something fishy here!'
, DooLog::Alert);
Or you can use the Alias methods instead of passing the log level:
1.
Doo::logger()->alert(
'Something fishy here!'
);
2.
Doo::logger()->emerg(
'message...'
);
3.
Doo::logger()->crit(
'message...'
);
4.
Doo::logger()->err(
'message...'
);
5.
Doo::logger()->warn(
'message...'
);
6.
Doo::logger()->notice(
'message...'
);
7.
Doo::logger()->info(
'message...'
);
8.
Doo::logger()->trace(
'message...'
);
All of the log messages can be organized by category, simply pass in another parameter at the end of the methods:
1.
Doo::logger()->log(
'Something fishy here!'
, DooLog::ALERT,
'editpost'
);
2.
Doo::logger()->emerg(
'message...'
,
'editpost'
);
3.
Doo::logger()->alert(
'message...'
,
'editpost'
);
To view the logged messages, you just have to call showLogs(). By default DooLog will return a neatly formatted XML log which can be filtered by level or category. You can get a plain text log if you need so:
01.
//display all logs
02.
echo
Doo::logger()->showLogs();
03.
04.
//display plain text log
05.
echo
Doo::logger()->showLogs(false);
06.
07.
//display only logs in category editpost
08.
echo
Doo::logger()->showLogs(true, null,
'editpost'
);
09.
10.
//display only logs in level Alert and category editpost
11.
echo
Doo::logger()->showLogs(true, DooLog::ALERT,
'editpost'
);
When you have to write the log messages into file, all you have to do is call writeLogs(). Similar to showLogs(), it writes the XML string to file by default.
1.
//Creates a log file