-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate Logging Infrastructure #1458
Conversation
This is in preperation for ugprading to Centos8
Just removing some now unused `use` statements & adding / updating documentation where needed.
Monolog does not support logging of arrays, so I've updated these calls to utilize json_encode.
There are a large number of code changes that appear to just change CCR::Log::X to CCR::Logging::X. Why the namespace change? to clarify: why not just change the internals of CCR::Log. The existing code would not then need to be modified and the code changes would be much more manageable. <EDIT 1> For example: - $logger = Log::factory('batch-export', $logConf);
+ $logger = Logging::singleton('batch-export', array('console' => array(), 'mysql' => array())); This code change would not be necessary at all if you write a function called factory that accepts the old style logConf varialbe) |
@@ -80,15 +81,15 @@ | |||
'mail' => false, | |||
'consoleLogLevel' => $logLevel | |||
); | |||
$logger = Log::factory('batch-export', $logConf); | |||
$logger = Logging::singleton('batch-export', array('console' => array(), 'mysql' => array())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just write a Log::factory function that does what we need? Then you wouldn't need to change most of this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this code change leaves an unused variable $logConf
- I highly suggest making a Log::factory() that accepts the original log configuration. then this file would not need to change at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the old code used $logLevel
as the console log level. The new code seems to ignore the logLevel setting. Again this bug would not exist if you make a Log::factory() that accepts the original log configuration
@@ -154,7 +155,11 @@ | |||
|
|||
if ( NULL !== $scriptOptions['verbosity'] ) $conf['consoleLogLevel'] = $scriptOptions['verbosity']; | |||
|
|||
$logger = Log::factory('etl_aggregation_table_manager', $conf); | |||
$logger = Logging::factory('etl_aggregation_table_manager', array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you make the Logging::factory function accept the $conf
varialbe in its current form? Also why change the namespace?
|
||
// ===================================================================== | ||
|
||
// NOTE: "process_start_time" is needed for log summary. | ||
$logger->notice(array( | ||
$logger->notice(json_encode(array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't you write a wrapper function that calls the monolog logger with a string? This would significantly reduce the amount of code changes (and hence the 'attack' surface of mistakes creeping in) it would also make it significantly easier to review the code and would have been less work.
case 'console': | ||
$level = array_key_exists('level', $typeConfig) | ||
? $typeConfig['level'] | ||
: self::getLevel(\xd_utilities\getConfiguration('logger', 'default_level_console'), Logger::NOTICE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old code defaulted to WARNING if the log level setting was absent from the configuration file:
protected static function getDefaultLogLevel($logType)
{
$option = 'default_level_' . $logType;
try {
$levelName = self::getConfiguration($option);
$level = constant(get_class() . '::' . strtoupper($levelName));
} catch (Exception $e) {
$level = self::WARNING;
}
return $level;
}
This PR is being replaced by #1461 |
Description
This PR swaps all Pear Log usage w/ Monolog.
CCR\Logging
class that takes the place ofCCR\Log
and utilizes Monolog.trace
level for now, but this can be re-added if we create a fork of Monolog as we did w/ Log.json_encode
but we have a number of other options when addressing this. We could stick w/ converting it pre-log call and useprint_r($message, true)
or a custom conversion function. If we choose to fork Monolog for a new Trace level then we could also updateLogger::addRecord
to utilize the sameextractMessage
function that Pear's Log class does.Motivation and Context
This PR came about from looking at what would be required to update XDMoD to support integrating Symfony Flex which requires PHP7. After speaking with Jeff about his students work towards the Centos8 / PHP7 goal he pointed me to https://docs.google.com/document/d/1fIr5ZzTrYdfO3aWP_sNouC-iojNfePqn3axMapJVsu4 which documents some of the currently known blockers for migrating XDMoD to Centos8 / PHP7. I started experimenting w/ a local docker image based on Jeff's students work and noticed that Pear Log required MDB2 which is not compatible w/ PHP7. After a brief conversation he had mentioned that we should probably replace our Logging prior to moving to PHP7, which got me thinking about how hard it would be to actually do. Turns out that it wasn't hard at all, just tedious. I also have branches ready to go for AppKernels, XSEDE and SUPREMM.
Tests performed
All automated tests for OpenXDMoD fresh install & upgrade
Checklist: