LoggingController.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
12 
14 
15 /**
16  * LoggingController is used to log a message in the backend log.
17  *
18  * The controller supports the following actions:
19  *
20  * <div class="controller-action">
21  * <div> __Action__ _default_ </div>
22  * <div>
23  * Log the message.
24  * | Parameter | Description
25  * |------------------------|-------------------------
26  * | _in_ `type` | The type of message. Must be one of: _DEBUG_, _INFO_, _WARNING_, _ERROR_, _FATAL_
27  * | _in_ `message` | The message
28  * | __Response Actions__ | |
29  * | `ok` | In all cases
30  * </div>
31  * </div>
32  *
33  * @author ingo herwig <ingo@wemove.com>
34  */
36 
37  /**
38  * @see Controller::doExecute()
39  */
40  protected function doExecute($method=null) {
41 
42  $request = $this->getRequest();
43  $response = $this->getResponse();
44  $logger = $this->getLogger();
45 
46  $logType = $request->getValue('type');
47  $message = $request->getValue('message');
48  switch($logType) {
49  case 'TRACE':
50  $logger->trace($message);
51  break;
52 
53  case 'DEBUG':
54  $logger->debug($message);
55  break;
56 
57  case 'INFO':
58  $logger->info($message);
59  break;
60 
61  case 'WARNING':
62  $logger->warn($message);
63  break;
64 
65  case 'ERROR':
66  $logger->error($message);
67  break;
68 
69  case 'FATAL':
70  $logger->fatal($message);
71  break;
72 
73  default:
74  $logger->error("Unknown log message type: ".$logType);
75  }
76 
77  $response->setAction('ok');
78  }
79 }
80 ?>
LoggingController is used to log a message in the backend log.
getLogger()
Get the Logger instance.
Definition: Controller.php:267
getRequest()
Get the Request instance.
Definition: Controller.php:251
Application controllers.
Definition: namespaces.php:3
Controller is the base class of all controllers.
Definition: Controller.php:49
getResponse()
Get the Response instance.
Definition: Controller.php:259