Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-13031

Standardise and improve logging of {auth,enrol}_sync scripts to assist automation

    Details

    • Affected Branches:
      MOODLE_19_STABLE

      Description

      Currently the synchronization scripts for auth and enrol (specifically, looking ext. database), log errors in a very inconsistent manner. I'm trying to integrate Moodle with an identity services backend that needs to be notified about successful and failed account ids. The current output format of the sync. scripts makes it difficult to parse the output and send it back to the XML-RPC server.

      I'd like to propose the following:
      1. that sync. scripts output messages in the following format (or an alternative, but consistent one).
      I'm illustrating the format using a perl-compatible regex.:
      /^(Warning|Error|Information):\s+[ID]\s+(DESCRIPTION)/
      where ID is the moodle account id number, and DESCRIPTION is the plaintext message

      2. that error messages are sent to STDERR and other messages are sent to STDOUT, for ease of capturing.

      I'm happy to update the auth and enrol plugins that I'm currently working with, and provide a patch. I'll now go ahead and update our custom enrolment plugin to do the same.

      Cheers,

      • Luke

        Gliffy Diagrams

          Activity

          Hide
          lukehudson Luke Hudson added a comment -

          In fact, perhaps the best thing would be a shared function. Something like the following:

          define('SYNC_LOG_INFO', 0);
          define('SYNC_LOG_WARNING', 1);
          define('SYNC_LOG_ERROR', 2);

          function sync_log_message($severity, $message, $uid = null)

          {....}

          // ------------------------------------------------------------------->8--

          sync_log_message( SYNC_LOG_ERROR, "Failed to connect to external database");
          sync_log_message( SYNC_LOG_WARNING, "Failed to update email field", $user->id );

          Show
          lukehudson Luke Hudson added a comment - In fact, perhaps the best thing would be a shared function. Something like the following: define('SYNC_LOG_INFO', 0); define('SYNC_LOG_WARNING', 1); define('SYNC_LOG_ERROR', 2); function sync_log_message($severity, $message, $uid = null) {....} // ------------------------------------------------------------------- >8 -- sync_log_message( SYNC_LOG_ERROR, "Failed to connect to external database"); sync_log_message( SYNC_LOG_WARNING, "Failed to update email field", $user->id );
          Hide
          skodak Petr Skoda added a comment -

          my +1 for that

          Show
          skodak Petr Skoda added a comment - my +1 for that

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: