aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/system_log.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-27 13:55:06 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-27 13:55:06 +0000
commitc10f2efcb71c5b7b8f990153a8ceb591571eaf4a (patch)
tree0926aee55c161531b7f2c2b5fc202745cd0f51d4 /engine/lib/system_log.php
parent398041e3e7c2551900d1a9e42b5efaa53ea23a2c (diff)
downloadelgg-c10f2efcb71c5b7b8f990153a8ceb591571eaf4a.tar.gz
elgg-c10f2efcb71c5b7b8f990153a8ceb591571eaf4a.tar.bz2
Refs #215: System hook for archiving log. Cron yet to be added.
git-svn-id: https://code.elgg.org/elgg/trunk@2314 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/system_log.php')
-rw-r--r--engine/lib/system_log.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/engine/lib/system_log.php b/engine/lib/system_log.php
index 4e862791d..f0aa14522 100644
--- a/engine/lib/system_log.php
+++ b/engine/lib/system_log.php
@@ -233,6 +233,30 @@
}
/**
+ * This function creates an archive copy of the system log.
+ */
+ function archive_log()
+ {
+ global $CONFIG;
+
+ $now = time(); // Take a snapshot of now
+
+ // create table
+ if (!update_data("CREATE TABLE {$CONFIG->dbprefix}system_log_$now as SELECT * from {$CONFIG->dbprefix}system_log WHERE time_created<=$now"))
+ return false;
+
+ // alter table to engine
+ if (!update_data("ALTER TABLE {$CONFIG->dbprefix}system_log_$now engine=archive"))
+ return false;
+
+ // delete
+ if (!delete_data("DELETE from {$CONFIG->dbprefix}system_log WHERE id in (select id from {$CONFIG->dbprefix}system_log_$now)")) // Don't delete on time since we are running in a concurrent environment
+ return false;
+
+ return true;
+ }
+
+ /**
* System log listener.
* This function listens to all events in the system and logs anything appropriate.
*