DefaultOutputStrategy.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 
16 
17 /**
18  * DefaultOutputStrategy outputs an object's content to the Log category DefaultOutputStrategy.
19  * Classes used must implement the toString() method.
20  *
21  * @author ingo herwig <ingo@wemove.com>
22  */
24 
25  private static $logger = null;
26 
27  /**
28  * Constructor
29  */
30  public function __construct() {
31  if (self::$logger == null) {
32  self::$logger = LogManager::getLogger(__CLASS__);
33  }
34  }
35 
36  /**
37  * @see OutputStrategy::writeHeader
38  */
39  public function writeHeader() {
40  if (self::$logger->isInfoEnabled()) {
41  self::$logger->info("DOCUMENT START.");
42  }
43  }
44 
45  /**
46  * @see OutputStrategy::writeFooter
47  */
48  public function writeFooter() {
49  if (self::$logger->isInfoEnabled()) {
50  self::$logger->info("DOCUMENT END.");
51  }
52  }
53 
54  /**
55  * @see OutputStrategy::writeObject
56  */
57  public function writeObject(PersistentObject $obj) {
58  if (self::$logger->isInfoEnabled()) {
59  self::$logger->info($obj->toString());
60  }
61  }
62 }
63 ?>
OutputStrategy defines the interface for classes that write an object's content to a destination (cal...
DefaultOutputStrategy outputs an object's content to the Log category DefaultOutputStrategy.
static getLogger($name)
Get the logger with the given name.
Definition: LogManager.php:37
PersistentObject defines the interface of all persistent objects.
LogManager is used to retrieve Logger instances.
Definition: LogManager.php:20