| 13 | | public static function main() |
|---|
| 14 | | { |
|---|
| 15 | | // initialize logger from configuration |
|---|
| 16 | | // in a default application using the |
|---|
| 17 | | // net.stubbles.websites.stubFrontController this can be done via the |
|---|
| 18 | | // net.stubbles.util.log.stubLogPreInterceptor |
|---|
| 19 | | $loggerXJConfFactory = new stubLoggerXJConfFactory(); |
|---|
| 20 | | $loggerXJConfFactory->init(); |
|---|
| | 13 | public static function main() |
|---|
| | 14 | { |
|---|
| | 15 | // initialize logger from configuration |
|---|
| | 16 | // in a default application using the |
|---|
| | 17 | // net.stubbles.websites.stubFrontController this can be done via the |
|---|
| | 18 | // net.stubbles.util.log.stubLogPreInterceptor |
|---|
| | 19 | $loggerXJConfFactory = new stubLoggerXJConfFactory(); |
|---|
| | 20 | $loggerXJConfFactory->init(); |
|---|
| 22 | | // both request and session normally are put into your application |
|---|
| 23 | | // classes e.g. via stub(Pre|Post)Interceptor::(pre|post)process() |
|---|
| 24 | | // or via stubPageElement::(isAvailable|process)() |
|---|
| 25 | | $request = new stubWebRequest(); |
|---|
| 26 | | $session = new stubPHPSession($request, 'SID'); |
|---|
| | 22 | // both request and session normally are put into your application |
|---|
| | 23 | // classes e.g. via stub(Pre|Post)Interceptor::(pre|post)process() |
|---|
| | 24 | // or via stubPageElement::(isAvailable|process)() |
|---|
| | 25 | $request = new stubWebRequest(); |
|---|
| | 26 | $session = new stubPHPSession($request, 'SID'); |
|---|
| 28 | | // now the real work for logging |
|---|
| 29 | | // first we create a new logdata object with target trail and level |
|---|
| 30 | | // info |
|---|
| 31 | | // the type of the logdata object can be configured in |
|---|
| 32 | | // config/xml/config.xml with the property net.stubbles.util.log.class |
|---|
| 33 | | // if property not set an instance of |
|---|
| 34 | | // net.stubbles.util.log.stubBaseLogData will be created |
|---|
| 35 | | $logData = stubLogDataFactory::create($session, 'trail', stubLogger::LEVEL_INFO); |
|---|
| | 28 | // now the real work for logging |
|---|
| | 29 | // first we create a new logdata object with target trail and level |
|---|
| | 30 | // info |
|---|
| | 31 | // the type of the logdata object can be configured in |
|---|
| | 32 | // config/xml/config.xml with the property net.stubbles.util.log.class |
|---|
| | 33 | // if property not set an instance of |
|---|
| | 34 | // net.stubbles.util.log.stubBaseLogData will be created |
|---|
| | 35 | $logData = stubLogDataFactory::create($session, 'trail', stubLogger::LEVEL_INFO); |
|---|
| 45 | | // now take a look into the log directory, there should be a logfile |
|---|
| 46 | | // named trail-Y-m-d.log containing the logdata |
|---|
| 47 | | // the contents are |
|---|
| 48 | | // [timestamp]|[session-id]|logging/index.php|foo |
|---|
| 49 | | } |
|---|
| | 45 | // now take a look into the log directory, there should be a logfile |
|---|
| | 46 | // named trail-Y-m-d.log containing the logdata |
|---|
| | 47 | // the contents are |
|---|
| | 48 | // [timestamp]|[session-id]|logging/index.php|foo |
|---|
| | 49 | |
|---|
| | 50 | // Display logs |
|---|
| | 51 | echo '<br /><br />The logfiles:<br />'; |
|---|
| | 52 | foreach (new DirectoryIterator(stubConfig::getLogPath()) as $log) { |
|---|
| | 53 | if ($log->isDot()) { |
|---|
| | 54 | continue; |
|---|
| | 55 | } |
|---|
| | 56 | if ($log->isDir()) { |
|---|
| | 57 | continue; |
|---|
| | 58 | } |
|---|
| | 59 | printf('<b>%s</b></br /><pre>%s</pre>', $log->getFilename(), file_get_contents($log->getPathname())); |
|---|
| | 60 | } |
|---|
| | 61 | } |
|---|