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

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Jan 9, 2016
1 parent 1a1b593 commit e79cfc3
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 17 deletions.
8 changes: 4 additions & 4 deletions INSTALL_5x
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ If you are using a "legacy siteaccess" by having set 'legacy_mode' in yml config

2. Follow the installation and configuration instructions of this extension for eZ Publish 4 (the INSTALL file)

2. Edit extension/ezperformancelogger/settings/site.ini.append.php, and disable the preoutput event listener, by
3. Edit extension/ezperformancelogger/settings/site.ini.append.php, and disable the preoutput event listener, by
commenting away the following line:

Listeners[]=response/preoutput@eZPerfLogger::preoutput

3. Edit your web/index.php file and add ...
4. Edit your web/index.php file and add ...

4. If in ezperformancelogger.ini you have set up any loggers which needs to rewrite output, edit services.yml: ...
5. If in ezperformancelogger.ini you have set up any loggers which needs to rewrite output, edit services.yml: ...

5. clear all caches (both eZ4 and eZ5 ones)
6. clear all caches (both eZ4 and eZ5 ones)
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Requirements:
. optionally: the xhprof profiler and graphviz
. optionally: the Monolog library and its dependencies


How it works: performance logging
---------------------------------

Expand Down Expand Up @@ -102,7 +103,6 @@ Notes:
just need instead to set AlwaysRegisterShutdownPerfLogger=enabled in ezperformacelogger.ini



How it works: profiling
-----------------------

Expand Down
2 changes: 1 addition & 1 deletion autoloads/ezperformanceloggeroperators.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) 2012-2014 G. Giunta
* @copyright (C) 2012-2016 G. Giunta
* @license code licensed under the GPL License: see LICENSE file
**/

Expand Down
41 changes: 38 additions & 3 deletions classes/ezperflogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,37 @@ static public function cleanup( $output='', $returnCode=null )
}
}

/**
* This function can be registered as shutdown handler using
* eZPerfLogger::registerShutdownPerfLogger( false, true);
* It differs from the cleanup function in that it only does anything when the cleanup handler is triggered by
* eZExecution::cleanExit() calls.
* This is useful to work around the fact that every time the eZ5 kernel does a runCallback(), it will call
* eZExecution::cleanup(), which triggers the cleanup handlers - but we do NOT want to run the perflogger
* logging code on each runCallback call - only on the last one.
* Of course this means a small performance hit, but unless the eZ kernel gets modified, we have little other choice...
*
* @param string $output
* @param int $returnCode
*/
static public function cleanupOnCleanExit( $output='', $returnCode=null )
{
foreach( debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ) as $call )
{
if ( @$call['class'] == 'eZExecution' && $call['function'] == 'cleanExit' )
{
return self::cleanup( $output, $returnCode );
}
}
}

/**
* This function can be registered as event handler for response/preoutput
* (mandatory since ezp 5.0 LS and later, as OutputFilter has been removed).
* NB: it only fires once, even if called many times
*
* @param string $output
* @param int $returnCode
*/
static public function preoutput( $output, $returnCode=null )
{
Expand All @@ -142,7 +169,7 @@ static public function preoutput( $output, $returnCode=null )
* @param bool $onlyIfConfigured when true, the registration only happens subject to an ini setting
* @return bool false if registration is aborted, true if the handler is (or was already) registered
*/
static public function registerShutdownPerfLogger( $onlyIfConfigured = false )
static public function registerShutdownPerfLogger( $onlyIfConfigured = false, $eZ5Context = false )
{
if ( $onlyIfConfigured && eZPerfLoggerINI::variable( 'GeneralSettings', 'AlwaysRegisterShutdownPerfLogger' ) !== 'enabled' )
{
Expand All @@ -151,13 +178,21 @@ static public function registerShutdownPerfLogger( $onlyIfConfigured = false )

foreach( eZExecution::cleanupHandlers() as $handler )
{
if ( $handler == array( __CLASS__, 'cleanup' ) )
if ( $handler == array( __CLASS__, 'cleanup' ) || $handler == array( __CLASS__, 'cleanupOnCleanExit' ) )
{
return true;
}
}

eZExecution::addCleanupHandler( array( __CLASS__, 'cleanup' ) );
if ( $eZ5Context )
{
eZExecution::addCleanupHandler( array( __CLASS__, 'cleanupOnCleanExit' ) );
}
else
{
eZExecution::addCleanupHandler( array( __CLASS__, 'cleanup' ) );
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion doc/specs_version_5
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ index.php is free to edit by developers:
- advantage: it runs only once
- it has access to response text, status code, and the legacy kernel
- it runs at the very end, possibly after output echoing to screen (good as long as you do not want to log to in-page)
- it allows us to disable response/preoutput filter (tested for both frontend and backend/legacy mode)
- it allows us to disable the response/preoutput filter (tested for both frontend and backend/legacy mode)
- what about cleanup handler registered via registerShutdownPerfLogger? => it is not enabled by default, luckily.
The problem with it is that cleanup handlers do get called on each runcallback() call ( see issue EZP-...), and
have no way to know if they are 'the real last one'...
Expand Down
2 changes: 1 addition & 1 deletion extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<name>ezperformancelogger</name>
<version>0.12.0</version>
<copyright>Copyright (C) 2010-2014 eZ Systems AS</copyright>
<copyright>Copyright (C) 2010-2016 eZ Systems AS</copyright>
<license>GNU General Public License v2.0</license>
<info_url>http://projects.ez.no/ezperformancelogger</info_url>

Expand Down
3 changes: 2 additions & 1 deletion ezinfo.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

class eZperformanceloggerInfo
{
static function info()
{
return array( 'Name' => "<a href=\"http://projects.ez.no/ezperformancelogger\">ezperformancelogger</a>",
'Version' => "0.12.0",
'Copyright' => "Copyright (C) 2010-2014 eZ Systems AS",
'Copyright' => "Copyright (C) 2010-2016 eZ Systems AS",
'License' => "GNU General Public License v2.0",
'3rdparty_software' =>
array ( 'name' => 'XHProf',
Expand Down
2 changes: 1 addition & 1 deletion modules/munin/module.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @author Gaetano Giunta
* @copyright (C) eZ Systems AS 2009-2014
* @copyright (C) eZ Systems AS 2009-2016
* @license code licensed under the GPL License: see README
*/

Expand Down
2 changes: 1 addition & 1 deletion modules/xhprof/list.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @author Gaetano Giunta
* @copyright (C) eZ Systems AS 2009-2014
* @copyright (C) eZ Systems AS 2009-2016
* @license code licensed under the GPL License: see README
*/

Expand Down
2 changes: 1 addition & 1 deletion modules/xhprof/module.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @author Gaetano Giunta
* @copyright (C) eZ Systems AS 2009-2014
* @copyright (C) eZ Systems AS 2009-2016
* @license code licensed under the GPL License: see README
*/

Expand Down
4 changes: 2 additions & 2 deletions settings/site.ini.append.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# This is the main mechanism used by this extension to trace all performance indicators (up to eZP 4.7).
# Do not disable this line.
[OutputSettings]
OutputFilterName=eZPerfLogger
###OutputFilterName=eZPerfLogger

# An extra type cache, where we store data of profiling runs.
# It is only used when integrating with XHProf, not for standard performance tracing
Expand All @@ -18,7 +18,7 @@
Listeners[]=content/cache@ezPerfLoggerEventListener::recordContentCache
Listeners[]=image/alias@ezPerfLoggerEventListener::recordImageAlias
# the following is an alternative to OutputFilterName=eZPerfLogger for ezpublish 5.0 LS and later
Listeners[]=response/preoutput@eZPerfLogger::preoutput
###Listeners[]=response/preoutput@eZPerfLogger::preoutput

# WARNING - HERE BE LIONS - WE EAT KITTENS FOR BREAKFAST

Expand Down

0 comments on commit e79cfc3

Please sign in to comment.