wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
class.LoggingController.php
Go to the documentation of this file.
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2014 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of any of the following licenses
7  * at your choice:
8  *
9  * - GNU Lesser General Public License (LGPL)
10  * http://www.gnu.org/licenses/lgpl.html
11  * - Eclipse Public License (EPL)
12  * http://www.eclipse.org/org/documents/epl-v10.php
13  *
14  * See the license.txt file distributed with this work for
15  * additional information.
16  *
17  * $Id$
18  */
19 require_once(BASE."wcmf/lib/presentation/class.Controller.php");
20 require_once(BASE."wcmf/lib/util/class.Log.php");
21 
22 /**
23  * @class LoggingController
24  * @ingroup Controller
25  * @brief LoggingController is a controller that logs a message.
26  *
27  * <b>Input actions:</b>
28  * - unspecified: Log the message
29  *
30  * <b>Output actions:</b>
31  * - @em ok In any case
32  *
33  * @param[in] type The type of message. Must be one of: DEBUG, INFO, WARNING, ERROR, FATAL
34  * @param[in] message The message
35  *
36  * @author ingo herwig <ingo@wemove.com>
37  */
39 {
40  /**
41  * @see Controller::hasView()
42  */
43  function hasView()
44  {
45  return false;
46  }
47  /**
48  * Log the message.
49  * @return Array of given context and action 'ok' in every case.
50  * @see Controller::executeKernel()
51  */
52  function executeKernel()
53  {
54  $logType = $this->_request->getValue('type');
55  $message = $this->_request->getValue('message');
56 
57  switch($logType)
58  {
59  case 'DEBUG':
60  Log::debug($message, __CLASS__);
61  break;
62 
63  case 'INFO':
64  Log::info($message, __CLASS__);
65  break;
66 
67  case 'WARNING':
68  Log::warn($message, __CLASS__);
69  break;
70 
71  case 'ERROR':
72  Log::error($message, __CLASS__);
73  break;
74 
75  case 'FATAL':
76  Log::fatal($message, __CLASS__);
77  break;
78 
79  default:
80  Log::error("Unknown log message type: ".$logType, __CLASS__);
81  }
82 
83  $this->_response->setAction('ok');
84  return true;
85  }
86 }
87 ?>
88 
error($message, $category)
Definition: class.Log.php:69
LoggingController is a controller that logs a message.
debug($message, $category)
Definition: class.Log.php:39
warn($message, $category)
Definition: class.Log.php:59
info($message, $category)
Definition: class.Log.php:49
Controller is the base class of all controllers. If a Controller has a view it is expected to reside ...
fatal($message, $category)
Definition: class.Log.php:79