LoggerAppender::write()
last analyzed

Size

Total Lines 1

Duplication

Lines 1
Ratio 100 %

Importance

Changes 0
Metric Value
nc 1
dl 1
loc 1
c 0
b 0
f 0
1
<?php
2
namespace Agavi\Logging;
3
4
// +---------------------------------------------------------------------------+
5
// | This file is part of the Agavi package.                                   |
6
// | Copyright (c) 2005-2011 the Agavi Project.                                |
7
// |                                                                           |
8
// | For the full copyright and license information, please view the LICENSE   |
9
// | file that was distributed with this source code. You can also view the    |
10
// | LICENSE file online at http://www.agavi.org/LICENSE.txt                   |
11
// |   vi: set noexpandtab:                                                    |
12
// |   Local Variables:                                                        |
13
// |   indent-tabs-mode: t                                                     |
14
// |   End:                                                                    |
15
// +---------------------------------------------------------------------------+
16
17
use Agavi\Core\Context;
18
use Agavi\Util\ParameterHolder;
19
20
/**
21
 * AgaviLoggerAppender allows you to specify a destination for log data and
22
 * provide a custom layout for it, through which all log messages will be
23
 * formatted.
24
 *
25
 * @package    agavi
26
 * @subpackage logging
27
 *
28
 * @author     David Zülke <[email protected]>
29
 * @author     Bob Zoller <[email protected]>
30
 * @copyright  Authors
31
 * @copyright  The Agavi Project
32
 *
33
 * @since      0.10.0
34
 *
35
 * @version    $Id$
36
 */
37 View Code Duplication
abstract class LoggerAppender extends ParameterHolder
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
{
39
    /**
40
     * @var        Context An Context instance.
41
     */
42
    protected $context = null;
43
44
    /**
45
     * @var        LoggerLayout An LoggerLayout instance.
46
     */
47
    protected $layout = null;
48
49
    /**
50
     * Initialize the object.
51
     *
52
     * @param      Context $context    A Context instance.
53
     * @param      array   $parameters An associative array of initialization parameters.
54
     *
55
     * @author     Bob Zoller <[email protected]>
56
     * @author     David Zülke <[email protected]>
57
     * @since      0.10.0
58
     */
59
    public function initialize(Context $context, array $parameters = array())
60
    {
61
        $this->context = $context;
62
        
63
        $this->setParameters($parameters);
64
    }
65
66
    /**
67
     * Retrieve the current application context.
68
     *
69
     * @return     Context A Context instance.
70
     *
71
     * @author     Sean Kerr <[email protected]>
72
     * @since      0.10.0
73
     */
74
    final public function getContext()
75
    {
76
        return $this->context;
77
    }
78
79
    /**
80
     * Retrieve the layout.
81
     *
82
     * @return     LoggerLayout A Layout instance, if it has been set,
83
     *                               otherwise null.
84
     *
85
     * @author     Sean Kerr <[email protected]>
86
     * @since      0.9.0
87
     */
88
    public function getLayout()
89
    {
90
        return $this->layout;
91
    }
92
93
    /**
94
     * Set the layout.
95
     *
96
     * @param      LoggerLayout $layout A Layout instance.
97
     *
98
     * @return     LoggerAppender
99
     *
100
     * @author     Sean Kerr <[email protected]>
101
     * @since      0.9.0
102
     */
103
    public function setLayout(LoggerLayout $layout)
104
    {
105
        $this->layout = $layout;
106
        return $this;
107
    }
108
109
    /**
110
     * Execute the shutdown procedure.
111
     *
112
     * @author     Sean Kerr <[email protected]>
113
     * @since      0.9.0
114
     */
115
    abstract function shutdown();
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
116
117
    /**
118
     * Write log data to this appender.
119
     *
120
     * @param      LoggerMessage $message Log data to be written.
121
     *
122
     * @author     Sean Kerr <[email protected]>
123
     * @since      0.9.0
124
     */
125
    abstract function write(LoggerMessage $message);
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
126
}
127