Logging with AOP in FLOW3

Logging in FLOW3 can be easily done by following the Aspect Oriented Programming (AOP) principle. You do not want to code the actual calls to your logging service into each of your functions which you want to log. In this example I am showing how to log the calls to a certain service which retrieves tweets from the Twitter API. In addition to that I also want to track the time it takes.

Create a Logging Aspect Class

MyPackage/Classes/Service/Logging/LoggingAspect.php

An @around joinPoint will do it . This log function will be called before the actual function is going to be executed. The function getTwitterFeed() is finally called by this statement:

As already described in a former article we use caching for retrieving the tweets. This gives us a huge speed bump.

Initial call, before caching the tweets:

Second call, now the data is received from cache:

Pretty fast now, huh?!

If you want to learn more about AOP in FLOW3 just check out the documentation.

UPDATE: Please note that every mention of FLOW3 changed to Flow since the release of TYPO3 Flow version 2.