Skip to content

Commit

Permalink
MDL-43759 logging: Rename trait writer to buffered_writer
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitagarwal authored and skodak committed Feb 28, 2014
1 parent ff2990a commit 8bae0d0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Helper trait writer
* Helper trait buffered_writer
*
* @package tool_log
* @copyright 2014 onwards Ankit Agarwal
Expand All @@ -26,14 +26,14 @@
defined('MOODLE_INTERNAL') || die();

/**
* Helper trait writer. Adds buffer support for the store.
* Helper trait buffered_writer. Adds buffer support for the store.
* \tool_log\helper\store must be included before using this trait.
*
* @package tool_log
* @copyright 2014 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
trait writer {
trait buffered_writer {

/** @var array $buffer buffer of events. */
protected $buffer = array();
Expand All @@ -45,8 +45,8 @@ trait writer {
protected $count = 0;

/**
* Write event in the store with buffering. Insert_events() must be
* defined. override in stores if the store doesn't support buffering.
* Write event in the store with buffering. Method insert_events() must be
* defined.
*
* @param \core\event\base $event
*
Expand Down Expand Up @@ -78,6 +78,23 @@ public function flush() {
$this->insert_events($events);
}

/**
* Bulk write a given array of events to the backend. Stores must implement this.
*
* @param array $events An array of events to write.
*/
abstract protected function insert_events($events);

/**
* Get a config value for the store.
*
* @param string $name Config name
* @param mixed $default default value
*
* @return mixed config value if set, else the default value.
*/
abstract protected function get_config($name, $default = null);

/**
* Push any remaining events to the database. Insert_events() must be
* defined. override in stores if the store doesn't support buffering.
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/log/store/database/classes/log/store.php
Expand Up @@ -28,7 +28,7 @@
class store implements \tool_log\log\writer, \core\log\reader {
use \tool_log\helper\store,
\tool_log\helper\reader,
\tool_log\helper\writer {
\tool_log\helper\buffered_writer {
dispose as helper_dispose;
}

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/log/store/standard/classes/log/store.php
Expand Up @@ -28,7 +28,7 @@

class store implements \tool_log\log\writer, \core\log\sql_reader {
use \tool_log\helper\store,
\tool_log\helper\writer,
\tool_log\helper\buffered_writer,
\tool_log\helper\reader;

/** @var string $logguests true if logging guest access */
Expand Down

0 comments on commit 8bae0d0

Please sign in to comment.