| 2 | | require '../config/php/config.php'; |
|---|
| 3 | | require '../lib/stubbles.php'; |
|---|
| 4 | | stubClassLoader::load('net.stubbles.util.log.stubLoggerXJConfFactory'); |
|---|
| | 2 | echo 'The PHP code:<br />'; |
|---|
| | 3 | echo highlight_file(__FILE__); |
|---|
| | 4 | |
|---|
| | 5 | require '../../config/php/config.php'; |
|---|
| | 6 | require '../bootstrap-stubbles.php'; |
|---|
| | 7 | stubClassLoader::load('net.stubbles.ipo.request.stubWebRequest', |
|---|
| | 8 | 'net.stubbles.ipo.session.stubPHPSession', |
|---|
| | 9 | 'net.stubbles.util.log.log', |
|---|
| | 10 | 'net.stubbles.util.log.stubLoggerXJConfFactory'); |
|---|
| 9 | | stubLoggerXJConfFactory::init('../config/xml/logging.xml'); |
|---|
| 10 | | echo '<pre>'; |
|---|
| 11 | | var_dump(stubLogger::getInstance()); |
|---|
| | 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(); |
|---|
| | 21 | |
|---|
| | 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'); |
|---|
| | 27 | |
|---|
| | 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); |
|---|
| | 36 | |
|---|
| | 37 | // we add some more data that we want to log |
|---|
| | 38 | $logData->addData('logging/index.php'); |
|---|
| | 39 | $logData->addData('foo'); |
|---|
| | 40 | |
|---|
| | 41 | // and finally we send the logdata to all log appenders that listen for |
|---|
| | 42 | // the level of the logdata (in this case stubLogger::LEVEL_INFO) |
|---|
| | 43 | stubLogger::logToAll($logData); |
|---|
| | 44 | |
|---|
| | 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 |
|---|