summaryrefslogtreecommitdiff
path: root/core/helpers/log.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-21 03:50:11 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-21 03:50:11 +0000
commitf0b633334416ecb86de0356a06932fcf78efbfb7 (patch)
tree2adb3e18cd09d04cd63f3be65c4e12ef26aa49ff /core/helpers/log.php
parenta19a4729b55ac72d487def1bc5da9f427c084ba9 (diff)
Add a logging facility, and instrument login/logout to use it.
Diffstat (limited to 'core/helpers/log.php')
-rw-r--r--core/helpers/log.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/core/helpers/log.php b/core/helpers/log.php
new file mode 100644
index 00000000..fece9de3
--- /dev/null
+++ b/core/helpers/log.php
@@ -0,0 +1,44 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class log_Core {
+ const INFO = 1;
+ const WARNING = 2;
+ const ERROR = 3;
+
+ /**
+ * Add a log entry.
+ *
+ * @param string $category an arbitrary category we can use to filter log messages
+ * @param string $message a detailed log message
+ * @param integer $severity INFO, WARNING or ERROR
+ * @param string $html an html snippet presented alongside the log message to aid the admin
+ */
+ function add($category, $message, $severity=INFO, $html) {
+ $log = ORM::factory("log");
+ $log->category = $category;
+ $log->message = $message;
+ $log->severity = $severity;
+ $log->html = $html;
+ $log->url = url::abs_current(true);
+ $log->referer = request::referrer(null);
+ $log->timestamp = time();
+ $log->save();
+ }
+}