├── .gitignore
├── LICENSE
├── README.md
├── config.cfg
├── server.py
├── shell.jpg
├── start.sh
├── tests
├── _bootstrap_.py
├── exc_shell.py
├── handshake.py
├── message_lengths.py
└── testsuite
│ ├── __init__.py
│ └── messages.py
├── tool
├── longtime.sh
├── start.sh
└── utils
│ └── check_process.sh
├── web
├── bootstrap
│ ├── css
│ │ ├── bootstrap-theme.css
│ │ ├── bootstrap-theme.css.map
│ │ ├── bootstrap-theme.min.css
│ │ ├── bootstrap.css
│ │ ├── bootstrap.css.map
│ │ ├── bootstrap.min.css
│ │ └── signin.css
│ ├── fonts
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.svg
│ │ ├── glyphicons-halflings-regular.ttf
│ │ ├── glyphicons-halflings-regular.woff
│ │ └── glyphicons-halflings-regular.woff2
│ └── js
│ │ ├── bootstrap.js
│ │ ├── bootstrap.min.js
│ │ ├── check.js
│ │ ├── check_add_shell.js
│ │ ├── check_change.js
│ │ ├── jquery-2.1.4.js
│ │ ├── modal.js
│ │ ├── npm.js
│ │ └── tooltip.js
├── config.json
├── config.php
├── index.php
├── log4php.properties
├── log4php
│ ├── Logger.php
│ ├── LoggerAppender.php
│ ├── LoggerAppenderPool.php
│ ├── LoggerAutoloader.php
│ ├── LoggerConfigurable.php
│ ├── LoggerConfigurator.php
│ ├── LoggerException.php
│ ├── LoggerFilter.php
│ ├── LoggerHierarchy.php
│ ├── LoggerLayout.php
│ ├── LoggerLevel.php
│ ├── LoggerLocationInfo.php
│ ├── LoggerLoggingEvent.php
│ ├── LoggerMDC.php
│ ├── LoggerNDC.php
│ ├── LoggerReflectionUtils.php
│ ├── LoggerRoot.php
│ ├── LoggerThrowableInformation.php
│ ├── appenders
│ │ ├── LoggerAppenderConsole.php
│ │ ├── LoggerAppenderDailyFile.php
│ │ ├── LoggerAppenderEcho.php
│ │ ├── LoggerAppenderFile.php
│ │ ├── LoggerAppenderFirePHP.php
│ │ ├── LoggerAppenderMail.php
│ │ ├── LoggerAppenderMailEvent.php
│ │ ├── LoggerAppenderMongoDB.php
│ │ ├── LoggerAppenderNull.php
│ │ ├── LoggerAppenderPDO.php
│ │ ├── LoggerAppenderPhp.php
│ │ ├── LoggerAppenderRollingFile.php
│ │ ├── LoggerAppenderSocket.php
│ │ └── LoggerAppenderSyslog.php
│ ├── configurators
│ │ ├── LoggerConfigurationAdapter.php
│ │ ├── LoggerConfigurationAdapterINI.php
│ │ ├── LoggerConfigurationAdapterPHP.php
│ │ ├── LoggerConfigurationAdapterXML.php
│ │ └── LoggerConfiguratorDefault.php
│ ├── filters
│ │ ├── LoggerFilterDenyAll.php
│ │ ├── LoggerFilterLevelMatch.php
│ │ ├── LoggerFilterLevelRange.php
│ │ └── LoggerFilterStringMatch.php
│ ├── helpers
│ │ ├── LoggerFormattingInfo.php
│ │ ├── LoggerOptionConverter.php
│ │ ├── LoggerPatternParser.php
│ │ └── LoggerUtils.php
│ ├── layouts
│ │ ├── LoggerLayoutHtml.php
│ │ ├── LoggerLayoutPattern.php
│ │ ├── LoggerLayoutSerialized.php
│ │ ├── LoggerLayoutSimple.php
│ │ ├── LoggerLayoutTTCC.php
│ │ └── LoggerLayoutXml.php
│ ├── pattern
│ │ ├── LoggerPatternConverter.php
│ │ ├── LoggerPatternConverterClass.php
│ │ ├── LoggerPatternConverterCookie.php
│ │ ├── LoggerPatternConverterDate.php
│ │ ├── LoggerPatternConverterEnvironment.php
│ │ ├── LoggerPatternConverterFile.php
│ │ ├── LoggerPatternConverterLevel.php
│ │ ├── LoggerPatternConverterLine.php
│ │ ├── LoggerPatternConverterLiteral.php
│ │ ├── LoggerPatternConverterLocation.php
│ │ ├── LoggerPatternConverterLogger.php
│ │ ├── LoggerPatternConverterMDC.php
│ │ ├── LoggerPatternConverterMessage.php
│ │ ├── LoggerPatternConverterMethod.php
│ │ ├── LoggerPatternConverterNDC.php
│ │ ├── LoggerPatternConverterNewLine.php
│ │ ├── LoggerPatternConverterProcess.php
│ │ ├── LoggerPatternConverterRelative.php
│ │ ├── LoggerPatternConverterRequest.php
│ │ ├── LoggerPatternConverterServer.php
│ │ ├── LoggerPatternConverterSession.php
│ │ ├── LoggerPatternConverterSessionID.php
│ │ ├── LoggerPatternConverterSuperglobal.php
│ │ └── LoggerPatternConverterThrowable.php
│ ├── renderers
│ │ ├── LoggerRenderer.php
│ │ ├── LoggerRendererDefault.php
│ │ ├── LoggerRendererException.php
│ │ └── LoggerRendererMap.php
│ └── xml
│ │ └── log4php.dtd
├── login.html
├── login.php
├── shell_manager.php
└── webdisk.log
└── websocket_server
├── __init__.py
└── websocket_server.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 |
5 | # C extensions
6 | *.so
7 |
8 | # Distribution / packaging
9 | .Python
10 | env/
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | *.egg-info/
23 | .installed.cfg
24 | *.egg
25 |
26 | # PyInstaller
27 | # Usually these files are written by a python script from a template
28 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
29 | *.manifest
30 | *.spec
31 |
32 | # Installer logs
33 | pip-log.txt
34 | pip-delete-this-directory.txt
35 |
36 | # Unit test / coverage reports
37 | htmlcov/
38 | .tox/
39 | .coverage
40 | .coverage.*
41 | .cache
42 | nosetests.xml
43 | coverage.xml
44 | *,cover
45 |
46 | # Translations
47 | *.mo
48 | *.pot
49 |
50 | # Django stuff:
51 | *.log
52 |
53 | # Sphinx documentation
54 | docs/_build/
55 |
56 | # PyBuilder
57 | target/
58 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 逐浪人
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Websocket Shell
2 | =======================
3 | web目录可以部署在任意的http服务器上
4 |
5 | web客户端可以通过注册账号和修改密码修改config.json的账号的信息
6 |
7 | 账号权限信息和可执行命令由超级用户在管理界面修改
8 |
9 | python通过配置文件config.cfg配置的url路径读取config.json的内容,主要用于校验
10 |
11 | 在python运行期间如果有新注册账户登录就重新读取url内容
12 |
13 | 这里解释一下用到的两个bison_key
14 |
15 | config.php用到的key主要用来加密密码和配置数据的接口,python获取数据的时候要用到同样的key
16 |
17 | login.php用到的key用来和时间戳生成一个token,JavaScript拿着这个token去和python建立连接,python在校验这个token的合法性时
18 | 需要用到同样的key
19 |
20 |
21 | 因为打开页面的浏览器需要跟server.py运行服务器在一个内网,因为他们需要建立socket链接
22 |
23 | 客户端的JavaScript通过websocket跟服务端的python建立链接,发送命令的id,服务端寻找id对应的命令然后执行
24 |
25 | 执行的结果实时回显在客户端的页面上
26 |
27 | 本项目从下面的项目修改而来
28 | https://github.com/Pithikos/python-websocket-server.git
29 |
30 | 之前一直想让普通用户在未获得linux账号的前提下执行一些linux或mac上的shell
31 | 如服务器更新,app发布,配置数据更新等
32 |
33 | 此前的做法一直是winscp或putty脚本来实现,缺点是不安全也不够灵活,账户和密码都在明文的脚本里边放着
34 |
35 | 本项目解决了这个问题,普通用户通过点击网页就可以完成执行命令的操作了
36 | 跟jenkins(http://jenkins-ci.org/ )的功能可能有重合,有时间了我去试下,不过这个项目更轻便一些
37 |
38 |
39 |
40 |
41 | 用法说明:
42 |
43 | 1. 将python-websocket-shell/web目录设置为网站的根目录
44 | 2. 删掉没必要的账号,注册新的账号,修改账号权限,数值越小权限越大,0是超级用户可以自由执行命令,不过这个“自由”仍然有限制
45 | 3. 超级用户通过管理页面修改脚本对应的权限值
46 | 4. 修改web/config.json的adrress为server.py监听的ip和端口,JavaScript要根据它与python服务器建立websocket连接
47 | 5. ./start.sh 启动websocket的服务端
48 | 6. 修改nginx的配置不允许访问config.json,现在即使允许访问也看不到密码,为防止暴力破解密码还是不允许的好
49 |
50 | 启动服务 ./start.sh
51 |
52 | 停止服务 ./start.sh stop
53 |
54 | web目录为root的nginx配置写法如下,location后面的位置是从web的根目录开始的
55 |
56 | location =/config.json{
57 | return 404;
58 | }
59 |
60 | apache的配置
61 |
62 |
The {@link decide()} method must return one 35 | * of the integer constants {@link LoggerFilter::DENY}, 36 | * {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::ACCEPT}. 37 | * 38 | *
If the value {@link LoggerFilter::DENY} is returned, then the log event is 39 | * dropped immediately without consulting with the remaining 40 | * filters. 41 | * 42 | *
If the value {@link LoggerFilter::NEUTRAL} is returned, then the next filter 43 | * in the chain is consulted. If there are no more filters in the 44 | * chain, then the log event is logged. Thus, in the presence of no 45 | * filters, the default behaviour is to log all logging events. 46 | * 47 | *
If the value {@link LoggerFilter::ACCEPT} is returned, then the log 48 | * event is logged without consulting the remaining filters. 49 | * 50 | *
The philosophy of log4php filters is largely inspired from the 51 | * Linux ipchains. 52 | * 53 | * @version $Revision: 1213283 $ 54 | * @package log4php 55 | */ 56 | abstract class LoggerFilter extends LoggerConfigurable { 57 | 58 | /** 59 | * The log event must be logged immediately without consulting with 60 | * the remaining filters, if any, in the chain. 61 | */ 62 | const ACCEPT = 1; 63 | 64 | /** 65 | * This filter is neutral with respect to the log event. The 66 | * remaining filters, if any, should be consulted for a final decision. 67 | */ 68 | const NEUTRAL = 0; 69 | 70 | /** 71 | * The log event must be dropped immediately without consulting 72 | * with the remaining filters, if any, in the chain. 73 | */ 74 | const DENY = -1; 75 | 76 | /** 77 | * @var LoggerFilter Points to the next {@link LoggerFilter} in the filter chain. 78 | */ 79 | protected $next; 80 | 81 | /** 82 | * Usually filters options become active when set. We provide a 83 | * default do-nothing implementation for convenience. 84 | */ 85 | public function activateOptions() { 86 | } 87 | 88 | /** 89 | * Decide what to do. 90 | *
If the decision is {@link LoggerFilter::DENY}, then the event will be
91 | * dropped. If the decision is {@link LoggerFilter::NEUTRAL}, then the next
92 | * filter, if any, will be invoked. If the decision is {@link LoggerFilter::ACCEPT} then
93 | * the event will be logged without consulting with other filters in
94 | * the chain.
95 | *
96 | * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon.
97 | * @return integer {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::DENY}|{@link LoggerFilter::ACCEPT}
98 | */
99 | public function decide(LoggerLoggingEvent $event) {
100 | return self::NEUTRAL;
101 | }
102 |
103 | /**
104 | * Adds a new filter to the filter chain this filter is a part of.
105 | * If this filter has already and follow up filter, the param filter
106 | * is passed on until it is the last filter in chain.
107 | *
108 | * @param $filter - the filter to add to this chain
109 | */
110 | public function addNext($filter) {
111 | if($this->next !== null) {
112 | $this->next->addNext($filter);
113 | } else {
114 | $this->next = $filter;
115 | }
116 | }
117 |
118 | /**
119 | * Returns the next filter in this chain
120 | * @return the next filter
121 | */
122 | public function getNext() {
123 | return $this->next;
124 | }
125 |
126 | }
127 |
--------------------------------------------------------------------------------
/web/log4php/LoggerLayout.php:
--------------------------------------------------------------------------------
1 | getRenderedMessage();
44 | }
45 |
46 | /**
47 | * Returns the content type output by this layout.
48 | * @return string
49 | */
50 | public function getContentType() {
51 | return "text/plain";
52 | }
53 |
54 | /**
55 | * Returns the footer for the layout format.
56 | * @return string
57 | */
58 | public function getFooter() {
59 | return null;
60 | }
61 |
62 | /**
63 | * Returns the header for the layout format.
64 | * @return string
65 | */
66 | public function getHeader() {
67 | return null;
68 | }
69 |
70 | /** Triggers a warning for this layout with the given message. */
71 | protected function warn($message) {
72 | trigger_error("log4php: [" . get_class($this) . "]: $message", E_USER_WARNING);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/web/log4php/LoggerLocationInfo.php:
--------------------------------------------------------------------------------
1 | lineNumber = isset($trace['line']) ? $trace['line'] : null;
71 | $this->fileName = isset($trace['file']) ? $trace['file'] : null;
72 | $this->className = isset($trace['class']) ? $trace['class'] : null;
73 | $this->methodName = isset($trace['function']) ? $trace['function'] : null;
74 | $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() .
75 | '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
76 | }
77 |
78 | /** Returns the caller class name. */
79 | public function getClassName() {
80 | return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className;
81 | }
82 |
83 | /** Returns the caller file name. */
84 | public function getFileName() {
85 | return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName;
86 | }
87 |
88 | /** Returns the caller line number. */
89 | public function getLineNumber() {
90 | return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber;
91 | }
92 |
93 | /** Returns the caller method name. */
94 | public function getMethodName() {
95 | return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName;
96 | }
97 |
98 | /** Returns the full information of the caller. */
99 | public function getFullInfo() {
100 | return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/web/log4php/LoggerMDC.php:
--------------------------------------------------------------------------------
1 | obj = $obj;
37 | }
38 |
39 | /**
40 | * Set the properties of an object passed as a parameter in one
41 | * go. The properties
are parsed relative to a
42 | * prefix
.
43 | *
44 | * @param object $obj The object to configure.
45 | * @param array $properties An array containing keys and values.
46 | * @param string $prefix Only keys having the specified prefix will be set.
47 | */
48 | // TODO: check, if this is really useful
49 | public static function setPropertiesByObject($obj, $properties, $prefix) {
50 | $pSetter = new LoggerReflectionUtils($obj);
51 | return $pSetter->setProperties($properties, $prefix);
52 | }
53 |
54 |
55 | /**
56 | * Set the properites for the object that match the
57 | * prefix
passed as parameter.
58 | *
59 | * Example:
60 | *
61 | * $arr['xxxname'] = 'Joe';
62 | * $arr['xxxmale'] = true;
63 | * and prefix xxx causes setName and setMale.
64 | *
65 | * @param array $properties An array containing keys and values.
66 | * @param string $prefix Only keys having the specified prefix will be set.
67 | */
68 | public function setProperties($properties, $prefix) {
69 | $len = strlen($prefix);
70 | reset($properties);
71 | while(list($key,) = each($properties)) {
72 | if(strpos($key, $prefix) === 0) {
73 | if(strpos($key, '.', ($len + 1)) > 0) {
74 | continue;
75 | }
76 | $value = $properties[$key];
77 | $key = substr($key, $len);
78 | if($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
79 | continue;
80 | }
81 | $this->setProperty($key, $value);
82 | }
83 | }
84 | $this->activate();
85 | }
86 |
87 | /**
88 | * Set a property on this PropertySetter's Object. If successful, this
89 | * method will invoke a setter method on the underlying Object. The
90 | * setter is the one for the specified property name and the value is
91 | * determined partly from the setter argument type and partly from the
92 | * value specified in the call to this method.
93 | *
94 | *
If the setter expects a String no conversion is necessary.
95 | * If it expects an int, then an attempt is made to convert 'value'
96 | * to an int using new Integer(value). If the setter expects a boolean,
97 | * the conversion is by new Boolean(value).
98 | *
99 | * @param string $name name of the property
100 | * @param string $value String value of the property
101 | */
102 | public function setProperty($name, $value) {
103 | if($value === null) {
104 | return;
105 | }
106 |
107 | $method = "set" . ucfirst($name);
108 |
109 | if(!method_exists($this->obj, $method)) {
110 | throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
111 | } else {
112 | return call_user_func(array($this->obj, $method), $value);
113 | }
114 | }
115 |
116 | public function activate() {
117 | if(method_exists($this->obj, 'activateoptions')) {
118 | return call_user_func(array($this->obj, 'activateoptions'));
119 | }
120 | }
121 |
122 | /**
123 | * Creates an instances from the given class name.
124 | *
125 | * @param string $classname
126 | * @return an object from the class with the given classname
127 | */
128 | public static function createObject($class) {
129 | if(!empty($class)) {
130 | return new $class();
131 | }
132 | return null;
133 | }
134 |
135 | /**
136 | * @param object $object
137 | * @param string $name
138 | * @param mixed $value
139 | */
140 | public static function setter($object, $name, $value) {
141 | if (empty($name)) {
142 | return false;
143 | }
144 | $methodName = 'set'.ucfirst($name);
145 | if (method_exists($object, $methodName)) {
146 | return call_user_func(array($object, $methodName), $value);
147 | } else {
148 | return false;
149 | }
150 | }
151 |
152 | }
153 |
--------------------------------------------------------------------------------
/web/log4php/LoggerRoot.php:
--------------------------------------------------------------------------------
1 | setLevel($level);
41 | }
42 |
43 | /**
44 | * @return LoggerLevel the level
45 | */
46 | public function getEffectiveLevel() {
47 | return $this->getLevel();
48 | }
49 |
50 | /**
51 | * Override level setter to prevent setting the root logger's level to
52 | * null. Root logger must always have a level.
53 | *
54 | * @param LoggerLevel $level
55 | */
56 | public function setLevel(LoggerLevel $level = null) {
57 | if (isset($level)) {
58 | parent::setLevel($level);
59 | } else {
60 | trigger_error("log4php: Cannot set LoggerRoot level to null.", E_USER_WARNING);
61 | }
62 | }
63 |
64 | /**
65 | * Override parent setter. Root logger cannot have a parent.
66 | * @param Logger $parent
67 | */
68 | public function setParent(Logger $parent) {
69 | trigger_error("log4php: LoggerRoot cannot have a parent.", E_USER_WARNING);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/web/log4php/LoggerThrowableInformation.php:
--------------------------------------------------------------------------------
1 | throwable = $throwable;
43 | }
44 |
45 | /**
46 | * Return source exception
47 | *
48 | * @return Exception
49 | */
50 | public function getThrowable() {
51 | return $this->throwable;
52 | }
53 |
54 | /**
55 | * @desc Returns string representation of throwable
56 | *
57 | * @return array
58 | */
59 | public function getStringRepresentation() {
60 | if (!is_array($this->throwableArray)) {
61 | $renderer = new LoggerRendererException();
62 |
63 | $this->throwableArray = explode("\n", $renderer->render($this->throwable));
64 | }
65 |
66 | return $this->throwableArray;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/web/log4php/appenders/LoggerAppenderConsole.php:
--------------------------------------------------------------------------------
1 | fp = fopen($this->target, 'w');
57 | if(is_resource($this->fp) && $this->layout !== null) {
58 | fwrite($this->fp, $this->layout->getHeader());
59 | }
60 | $this->closed = (bool)is_resource($this->fp) === false;
61 | }
62 |
63 |
64 | public function close() {
65 | if($this->closed != true) {
66 | if (is_resource($this->fp) && $this->layout !== null) {
67 | fwrite($this->fp, $this->layout->getFooter());
68 | fclose($this->fp);
69 | }
70 | $this->closed = true;
71 | }
72 | }
73 |
74 | public function append(LoggerLoggingEvent $event) {
75 | if (is_resource($this->fp) && $this->layout !== null) {
76 | fwrite($this->fp, $this->layout->format($event));
77 | }
78 | }
79 |
80 | /**
81 | * Sets the 'target' parameter.
82 | * @param string $target
83 | */
84 | public function setTarget($target) {
85 | $value = trim($target);
86 | if ($value == self::STDOUT || strtoupper($value) == 'STDOUT') {
87 | $this->target = self::STDOUT;
88 | } elseif ($value == self::STDERR || strtoupper($value) == 'STDERR') {
89 | $this->target = self::STDERR;
90 | } else {
91 | $target = var_export($target);
92 | $this->warn("Invalid value given for 'target' property: [$target]. Property not set.");
93 | }
94 | }
95 |
96 | /**
97 | * Returns the value of the 'target' parameter.
98 | * @return string
99 | */
100 | public function getTarget() {
101 | return $this->target;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/web/log4php/appenders/LoggerAppenderDailyFile.php:
--------------------------------------------------------------------------------
1 | datePattern)) {
64 | $this->warn("Required parameter 'datePattern' not set. Closing appender.");
65 | $this->closed = true;
66 | return;
67 | }
68 | }
69 |
70 | /**
71 | * Appends a logging event.
72 | *
73 | * If the target file changes because of passage of time (e.g. at midnight)
74 | * the current file is closed. A new file, with the new date, will be
75 | * opened by the write() method.
76 | */
77 | public function append(LoggerLoggingEvent $event) {
78 | $eventDate = $this->getDate($event->getTimestamp());
79 |
80 | // Initial setting of current date
81 | if (!isset($this->currentDate)) {
82 | $this->currentDate = $eventDate;
83 | }
84 |
85 | // Check if rollover is needed
86 | else if ($this->currentDate !== $eventDate) {
87 | $this->currentDate = $eventDate;
88 |
89 | // Close the file if it's open.
90 | // Note: $this->close() is not called here because it would set
91 | // $this->closed to true and the appender would not recieve
92 | // any more logging requests
93 | if (is_resource($this->fp)) {
94 | $this->write($this->layout->getFooter());
95 | fclose($this->fp);
96 | }
97 | $this->fp = null;
98 | }
99 |
100 | parent::append($event);
101 | }
102 |
103 | /** Renders the date using the configured datePattern. */
104 | protected function getDate($timestamp = null) {
105 | return date($this->datePattern, $timestamp);
106 | }
107 |
108 | /**
109 | * Determines target file. Replaces %s in file path with a date.
110 | */
111 | protected function getTargetFile() {
112 | return str_replace('%s', $this->currentDate, $this->file);
113 | }
114 |
115 | /**
116 | * Sets the 'datePattern' parameter.
117 | * @param string $datePattern
118 | */
119 | public function setDatePattern($datePattern) {
120 | $this->setString('datePattern', $datePattern);
121 | }
122 |
123 | /**
124 | * Returns the 'datePattern' parameter.
125 | * @return string
126 | */
127 | public function getDatePattern() {
128 | return $this->datePattern;
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/web/log4php/appenders/LoggerAppenderEcho.php:
--------------------------------------------------------------------------------
1 | element will be inserted
27 | * before each line break in the logged message. Default is false.
28 | *
29 | * @version $Revision: 1337820 $
30 | * @package log4php
31 | * @subpackage appenders
32 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
33 | * @link http://logging.apache.org/log4php/docs/appenders/echo.html Appender documentation
34 | */
35 | class LoggerAppenderEcho extends LoggerAppender {
36 | /**
37 | * Used to mark first append. Set to false after first append.
38 | * @var boolean
39 | */
40 | protected $firstAppend = true;
41 |
42 | /**
43 | * If set to true, a
35 | * The corresponding XML file:
36 | *
37 | * {@example ../../examples/resources/filter_denyall.xml 18}
38 | *
39 | * @version $Revision: 883108 $
40 | * @package log4php
41 | * @subpackage filters
42 | * @since 0.3
43 | */
44 | class LoggerFilterDenyAll extends LoggerFilter {
45 |
46 | /**
47 | * Always returns the integer constant {@link LoggerFilter::DENY}
48 | * regardless of the {@link LoggerLoggingEvent} parameter.
49 | *
50 | * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter.
51 | * @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY}
52 | */
53 | public function decide(LoggerLoggingEvent $event) {
54 | return LoggerFilter::DENY;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/web/log4php/filters/LoggerFilterLevelMatch.php:
--------------------------------------------------------------------------------
1 | The filter admits two options LevelToMatch and
25 | * AcceptOnMatch. If there is an exact match between the value
26 | * of the LevelToMatch option and the level of the
27 | * {@link LoggerLoggingEvent}, then the {@link decide()} method returns
28 | * {@link LoggerFilter::ACCEPT} in case the AcceptOnMatch
29 | * option value is set to true, if it is false then
30 | * {@link LoggerFilter::DENY} is returned. If there is no match,
31 | * {@link LoggerFilter::NEUTRAL} is returned.
34 | * An example for this filter:
35 | *
36 | * {@example ../../examples/php/filter_levelmatch.php 19}
37 | *
38 | *
39 | * The corresponding XML file:
40 | *
41 | * {@example ../../examples/resources/filter_levelmatch.xml 18}
42 | *
43 | * @version $Revision: 1213283 $
44 | * @package log4php
45 | * @subpackage filters
46 | * @since 0.6
47 | */
48 | class LoggerFilterLevelMatch extends LoggerFilter {
49 |
50 | /**
51 | * Indicates if this event should be accepted or denied on match
52 | * @var boolean
53 | */
54 | protected $acceptOnMatch = true;
55 |
56 | /**
57 | * The level, when to match
58 | * @var LoggerLevel
59 | */
60 | protected $levelToMatch;
61 |
62 | /**
63 | * @param boolean $acceptOnMatch
64 | */
65 | public function setAcceptOnMatch($acceptOnMatch) {
66 | $this->setBoolean('acceptOnMatch', $acceptOnMatch);
67 | }
68 |
69 | /**
70 | * @param string $l the level to match
71 | */
72 | public function setLevelToMatch($level) {
73 | $this->setLevel('levelToMatch', $level);
74 | }
75 |
76 | /**
77 | * Return the decision of this filter.
78 | *
79 | * Returns {@link LoggerFilter::NEUTRAL} if the LevelToMatch
80 | * option is not set or if there is not match. Otherwise, if there is a
81 | * match, then the returned decision is {@link LoggerFilter::ACCEPT} if the
82 | * AcceptOnMatch property is set to true. The
83 | * returned decision is {@link LoggerFilter::DENY} if the
84 | * AcceptOnMatch property is set to false.
85 | *
86 | * @param LoggerLoggingEvent $event
87 | * @return integer
88 | */
89 | public function decide(LoggerLoggingEvent $event) {
90 | if($this->levelToMatch === null) {
91 | return LoggerFilter::NEUTRAL;
92 | }
93 |
94 | if($this->levelToMatch->equals($event->getLevel())) {
95 | return $this->acceptOnMatch ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
96 | } else {
97 | return LoggerFilter::NEUTRAL;
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/web/log4php/filters/LoggerFilterLevelRange.php:
--------------------------------------------------------------------------------
1 | The filter admits three options LevelMin, LevelMax
26 | * and AcceptOnMatch. If the level of the {@link LoggerLoggingEvent} is not between Min and Max
29 | * (inclusive), then {@link LoggerFilter::DENY} is returned. If the Logging event level is within the specified range, then if
32 | * AcceptOnMatch is true,
33 | * {@link LoggerFilter::ACCEPT} is returned, and if
34 | * AcceptOnMatch is false,
35 | * {@link LoggerFilter::NEUTRAL} is returned. If LevelMin is not defined, then there is no
38 | * minimum acceptable level (i.e. a level is never rejected for
39 | * being too "low"/unimportant). If LevelMax is not
40 | * defined, then there is no maximum acceptable level (ie a
41 | * level is never rejected for being too "high"/important). Refer to the {@link LoggerAppender::setThreshold()} method
44 | * available to all appenders extending {@link LoggerAppender}
45 | * for a more convenient way to filter out events by level.
48 | * An example for this filter:
49 | *
50 | * {@example ../../examples/php/filter_levelrange.php 19}
51 | *
52 | *
53 | * The corresponding XML file:
54 | *
55 | * {@example ../../examples/resources/filter_levelrange.xml 18}
56 | *
57 | * @author Simon Kitching
58 | * @author based on the org.apache.log4j.varia.LevelRangeFilte Java code by Ceki Gülcü
59 | *
60 | * @version $Revision: 1213283 $
61 | * @package log4php
62 | * @subpackage filters
63 | * @since 0.6
64 | */
65 | class LoggerFilterLevelRange extends LoggerFilter {
66 |
67 | /**
68 | * @var boolean
69 | */
70 | protected $acceptOnMatch = true;
71 |
72 | /**
73 | * @var LoggerLevel
74 | */
75 | protected $levelMin;
76 |
77 | /**
78 | * @var LoggerLevel
79 | */
80 | protected $levelMax;
81 |
82 | /**
83 | * @param boolean $acceptOnMatch
84 | */
85 | public function setAcceptOnMatch($acceptOnMatch) {
86 | $this->setBoolean('acceptOnMatch', $acceptOnMatch);
87 | }
88 |
89 | /**
90 | * @param string $l the level min to match
91 | */
92 | public function setLevelMin($level) {
93 | $this->setLevel('levelMin', $level);
94 | }
95 |
96 | /**
97 | * @param string $l the level max to match
98 | */
99 | public function setLevelMax($level) {
100 | $this->setLevel('levelMax', $level);
101 | }
102 |
103 | /**
104 | * Return the decision of this filter.
105 | *
106 | * @param LoggerLoggingEvent $event
107 | * @return integer
108 | */
109 | public function decide(LoggerLoggingEvent $event) {
110 | $level = $event->getLevel();
111 |
112 | if($this->levelMin !== null) {
113 | if($level->isGreaterOrEqual($this->levelMin) == false) {
114 | // level of event is less than minimum
115 | return LoggerFilter::DENY;
116 | }
117 | }
118 |
119 | if($this->levelMax !== null) {
120 | if($level->toInt() > $this->levelMax->toInt()) {
121 | // level of event is greater than maximum
122 | // Alas, there is no Level.isGreater method. and using
123 | // a combo of isGreaterOrEqual && !Equal seems worse than
124 | // checking the int values of the level objects..
125 | return LoggerFilter::DENY;
126 | }
127 | }
128 |
129 | if($this->acceptOnMatch) {
130 | // this filter set up to bypass later filters and always return
131 | // accept if level in range
132 | return LoggerFilter::ACCEPT;
133 | } else {
134 | // event is ok for this filter; allow later filters to have a look..
135 | return LoggerFilter::NEUTRAL;
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/web/log4php/filters/LoggerFilterStringMatch.php:
--------------------------------------------------------------------------------
1 | The filter admits two options {@link $stringToMatch} and
25 | * {@link $acceptOnMatch}. If there is a match (using {@link PHP_MANUAL#strpos}
26 | * between the value of the {@link $stringToMatch} option and the message
27 | * of the {@link LoggerLoggingEvent},
28 | * then the {@link decide()} method returns {@link LoggerFilter::ACCEPT} if
29 | * the AcceptOnMatch option value is true, if it is false then
30 | * {@link LoggerFilter::DENY} is returned. If there is no match, {@link LoggerFilter::NEUTRAL}
31 | * is returned.
34 | * An example for this filter:
35 | *
36 | * {@example ../../examples/php/filter_stringmatch.php 19}
37 | *
38 | *
39 | * The corresponding XML file:
40 | *
41 | * {@example ../../examples/resources/filter_stringmatch.xml 18}
42 | *
43 | * @version $Revision: 1213283 $
44 | * @package log4php
45 | * @subpackage filters
46 | * @since 0.3
47 | */
48 | class LoggerFilterStringMatch extends LoggerFilter {
49 |
50 | /**
51 | * @var boolean
52 | */
53 | protected $acceptOnMatch = true;
54 |
55 | /**
56 | * @var string
57 | */
58 | protected $stringToMatch;
59 |
60 | /**
61 | * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
62 | */
63 | public function setAcceptOnMatch($acceptOnMatch) {
64 | $this->setBoolean('acceptOnMatch', $acceptOnMatch);
65 | }
66 |
67 | /**
68 | * @param string $s the string to match
69 | */
70 | public function setStringToMatch($string) {
71 | $this->setString('stringToMatch', $string);
72 | }
73 |
74 | /**
75 | * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
76 | */
77 | public function decide(LoggerLoggingEvent $event) {
78 | $msg = $event->getRenderedMessage();
79 |
80 | if($msg === null or $this->stringToMatch === null) {
81 | return LoggerFilter::NEUTRAL;
82 | }
83 |
84 | if(strpos($msg, $this->stringToMatch) !== false ) {
85 | return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
86 | }
87 | return LoggerFilter::NEUTRAL;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/web/log4php/helpers/LoggerFormattingInfo.php:
--------------------------------------------------------------------------------
1 | $fragment) {
47 | if (trim($fragment) === '') {
48 | unset($fragments[$key]);
49 | }
50 | }
51 |
52 | return $fragments;
53 | }
54 |
55 | /**
56 | * Attempts to shorten the given class name to the desired length.
57 | *
58 | * This is done by separating the class name into fragments (delimited
59 | * by \ or .) and trimming individual fragments, starting with the left,
60 | * until desired length has been reached.
61 | *
62 | * The final fragment (i.e. class name) will never be shortened so the
63 | * result may still be longer than given length.
64 | *
65 | * @param string $name The (qualified) class name.
66 | * @param integer $length The length to shorten to. If null or 0 is given,
67 | * the name will be returned without shortening.
68 | */
69 | public static function shortenClassName($name, $length) {
70 | if ($length === null || $length < 0) {
71 | return $name;
72 | }
73 |
74 | $name = str_replace('.', '\\', $name);
75 | $name = trim($name, ' \\');
76 |
77 | // Check if any shortening is required
78 | $currentLength = strlen($name);
79 | if ($currentLength <= $length) {
80 | return $name;
81 | }
82 |
83 | // Split name into fragments
84 | $fragments = explode('\\', $name);
85 |
86 | // If zero length is specified, return only last fragment
87 | if ($length == 0) {
88 | return array_pop($fragments);
89 | }
90 |
91 | // If the name splits to only one fragment, then it cannot be shortened
92 | $count = count($fragments);
93 | if ($count == 1) {
94 | return $name;
95 | }
96 |
97 | foreach($fragments as $key => &$fragment) {
98 |
99 | // Never shorten last fragment
100 | if ($key == $count - 1) {
101 | break;
102 | }
103 |
104 | // Check for empty fragments (shouldn't happen but it's possible)
105 | $fragLen = strlen($fragment);
106 | if ($fragLen <= 1) {
107 | continue;
108 | }
109 |
110 | // Shorten fragment to one character and check if total length satisfactory
111 | $fragment = substr($fragment, 0, 1);
112 | $currentLength = $currentLength - $fragLen + 1;
113 |
114 | if ($currentLength <= $length) {
115 | break;
116 | }
117 | }
118 | unset($fragment);
119 |
120 | return implode('\\', $fragments);
121 | }
122 | }
123 |
124 |
--------------------------------------------------------------------------------
/web/log4php/layouts/LoggerLayoutPattern.php:
--------------------------------------------------------------------------------
1 | 'LoggerPatternConverterLogger',
47 | 'lo' => 'LoggerPatternConverterLogger',
48 | 'logger' => 'LoggerPatternConverterLogger',
49 |
50 | 'C' => 'LoggerPatternConverterClass',
51 | 'class' => 'LoggerPatternConverterClass',
52 |
53 | 'cookie' => 'LoggerPatternConverterCookie',
54 |
55 | 'd' => 'LoggerPatternConverterDate',
56 | 'date' => 'LoggerPatternConverterDate',
57 |
58 | 'e' => 'LoggerPatternConverterEnvironment',
59 | 'env' => 'LoggerPatternConverterEnvironment',
60 |
61 | 'ex' => 'LoggerPatternConverterThrowable',
62 | 'exception' => 'LoggerPatternConverterThrowable',
63 | 'throwable' => 'LoggerPatternConverterThrowable',
64 |
65 | 'F' => 'LoggerPatternConverterFile',
66 | 'file' => 'LoggerPatternConverterFile',
67 |
68 | 'l' => 'LoggerPatternConverterLocation',
69 | 'location' => 'LoggerPatternConverterLocation',
70 |
71 | 'L' => 'LoggerPatternConverterLine',
72 | 'line' => 'LoggerPatternConverterLine',
73 |
74 | 'm' => 'LoggerPatternConverterMessage',
75 | 'msg' => 'LoggerPatternConverterMessage',
76 | 'message' => 'LoggerPatternConverterMessage',
77 |
78 | 'M' => 'LoggerPatternConverterMethod',
79 | 'method' => 'LoggerPatternConverterMethod',
80 |
81 | 'n' => 'LoggerPatternConverterNewLine',
82 | 'newline' => 'LoggerPatternConverterNewLine',
83 |
84 | 'p' => 'LoggerPatternConverterLevel',
85 | 'le' => 'LoggerPatternConverterLevel',
86 | 'level' => 'LoggerPatternConverterLevel',
87 |
88 | 'r' => 'LoggerPatternConverterRelative',
89 | 'relative' => 'LoggerPatternConverterRelative',
90 |
91 | 'req' => 'LoggerPatternConverterRequest',
92 | 'request' => 'LoggerPatternConverterRequest',
93 |
94 | 's' => 'LoggerPatternConverterServer',
95 | 'server' => 'LoggerPatternConverterServer',
96 |
97 | 'ses' => 'LoggerPatternConverterSession',
98 | 'session' => 'LoggerPatternConverterSession',
99 |
100 | 'sid' => 'LoggerPatternConverterSessionID',
101 | 'sessionid' => 'LoggerPatternConverterSessionID',
102 |
103 | 't' => 'LoggerPatternConverterProcess',
104 | 'pid' => 'LoggerPatternConverterProcess',
105 | 'process' => 'LoggerPatternConverterProcess',
106 |
107 | 'x' => 'LoggerPatternConverterNDC',
108 | 'ndc' => 'LoggerPatternConverterNDC',
109 |
110 | 'X' => 'LoggerPatternConverterMDC',
111 | 'mdc' => 'LoggerPatternConverterMDC',
112 | );
113 |
114 | /** Maps conversion keywords to the relevant converter. */
115 | protected $converterMap = array();
116 |
117 | /**
118 | * Head of a chain of Converters.
119 | * @var LoggerPatternConverter
120 | */
121 | private $head;
122 |
123 | /** Returns the default converter map. */
124 | public static function getDefaultConverterMap() {
125 | return self::$defaultConverterMap;
126 | }
127 |
128 | /** Constructor. Initializes the converter map. */
129 | public function __construct() {
130 | $this->converterMap = self::$defaultConverterMap;
131 | }
132 |
133 | /**
134 | * Sets the conversionPattern option. This is the string which
135 | * controls formatting and consists of a mix of literal content and
136 | * conversion specifiers.
137 | * @param array $conversionPattern
138 | */
139 | public function setConversionPattern($conversionPattern) {
140 | $this->pattern = $conversionPattern;
141 | }
142 |
143 | /**
144 | * Processes the conversion pattern and creates a corresponding chain of
145 | * pattern converters which will be used to format logging events.
146 | */
147 | public function activateOptions() {
148 | if (!isset($this->pattern)) {
149 | throw new LoggerException("Mandatory parameter 'conversionPattern' is not set.");
150 | }
151 |
152 | $parser = new LoggerPatternParser($this->pattern, $this->converterMap);
153 | $this->head = $parser->parse();
154 | }
155 |
156 | /**
157 | * Produces a formatted string as specified by the conversion pattern.
158 | *
159 | * @param LoggerLoggingEvent $event
160 | * @return string
161 | */
162 | public function format(LoggerLoggingEvent $event) {
163 | $sbuf = '';
164 | $converter = $this->head;
165 | while ($converter !== null) {
166 | $converter->format($sbuf, $event);
167 | $converter = $converter->next;
168 | }
169 | return $sbuf;
170 | }
171 | }
--------------------------------------------------------------------------------
/web/log4php/layouts/LoggerLayoutSerialized.php:
--------------------------------------------------------------------------------
1 | setBoolean('locationInfo', $value);
41 | }
42 |
43 | /** Returns the location information flag. */
44 | public function getLocationInfo() {
45 | return $this->locationInfo;
46 | }
47 |
48 | public function format(LoggerLoggingEvent $event) {
49 | // If required, initialize the location data
50 | if($this->locationInfo) {
51 | $event->getLocationInformation();
52 | }
53 | return serialize($event) . PHP_EOL;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/web/log4php/layouts/LoggerLayoutSimple.php:
--------------------------------------------------------------------------------
1 | level, followed by " - " and then the message.
26 | *
27 | * For example the following php and properties files
28 | *
29 | * {@example ../../examples/php/layout_simple.php 19} Each of the four fields can be individually enabled or
26 | * disabled. The time format depends on the DateFormat used. If no dateFormat is specified it defaults to '%c'.
29 | * See php {@link PHP_MANUAL#date} function for details. Time, thread, category are printed depending on options.
159 | *
160 | * @param LoggerLoggingEvent $event
161 | * @return string
162 | */
163 | public function format(LoggerLoggingEvent $event) {
164 | $timeStamp = (float)$event->getTimeStamp();
165 | $format = strftime($this->dateFormat, (int)$timeStamp);
166 |
167 | if ($this->microSecondsPrinting) {
168 | $usecs = floor(($timeStamp - (int)$timeStamp) * 1000);
169 | $format .= sprintf(',%03d', $usecs);
170 | }
171 |
172 | $format .= ' ';
173 |
174 | if ($this->threadPrinting) {
175 | $format .= '['.getmypid().'] ';
176 | }
177 |
178 | $level = $event->getLevel();
179 | $format .= $level.' ';
180 |
181 | if($this->categoryPrefixing) {
182 | $format .= $event->getLoggerName().' ';
183 | }
184 |
185 | if($this->contextPrinting) {
186 | $ndc = $event->getNDC();
187 | if($ndc != null) {
188 | $format .= $ndc.' ';
189 | }
190 | }
191 |
192 | $format .= '- '.$event->getRenderedMessage();
193 | $format .= PHP_EOL;
194 |
195 | return $format;
196 | }
197 |
198 | public function ignoresThrowable() {
199 | return true;
200 | }
201 | }
202 |
--------------------------------------------------------------------------------
/web/log4php/layouts/LoggerLayoutXml.php:
--------------------------------------------------------------------------------
1 | It does not output a complete well-formed XML file.
32 | * The output is designed to be included as an external entity in a separate file to form
33 | * a correct XML file.
element will be inserted before each line
44 | * break in the logged message. Default value is false. @var boolean
45 | */
46 | protected $htmlLineBreaks = false;
47 |
48 | public function close() {
49 | if($this->closed != true) {
50 | if(!$this->firstAppend) {
51 | echo $this->layout->getFooter();
52 | }
53 | }
54 | $this->closed = true;
55 | }
56 |
57 | public function append(LoggerLoggingEvent $event) {
58 | if($this->layout !== null) {
59 | if($this->firstAppend) {
60 | echo $this->layout->getHeader();
61 | $this->firstAppend = false;
62 | }
63 | $text = $this->layout->format($event);
64 |
65 | if ($this->htmlLineBreaks) {
66 | $text = nl2br($text);
67 | }
68 | echo $text;
69 | }
70 | }
71 |
72 | /**
73 | * Sets the 'htmlLineBreaks' parameter.
74 | * @param boolean $value
75 | */
76 | public function setHtmlLineBreaks($value) {
77 | $this->setBoolean('htmlLineBreaks', $value);
78 | }
79 |
80 | /**
81 | * Returns the 'htmlLineBreaks' parameter.
82 | * @returns boolean
83 | */
84 | public function getHtmlLineBreaks() {
85 | return $this->htmlLineBreaks;
86 | }
87 | }
88 |
89 |
--------------------------------------------------------------------------------
/web/log4php/appenders/LoggerAppenderFile.php:
--------------------------------------------------------------------------------
1 | file;
73 | }
74 |
75 | /**
76 | * Acquires the target file resource, creates the destination folder if
77 | * necessary. Writes layout header to file.
78 | *
79 | * @return boolean FALSE if opening failed
80 | */
81 | protected function openFile() {
82 | $file = $this->getTargetFile();
83 |
84 | // Create the target folder if needed
85 | if(!is_file($file)) {
86 | $dir = dirname($file);
87 |
88 | if(!is_dir($dir)) {
89 | $success = mkdir($dir, 0777, true);
90 | if ($success === false) {
91 | $this->warn("Failed creating target directory [$dir]. Closing appender.");
92 | $this->closed = true;
93 | return false;
94 | }
95 | }
96 | }
97 |
98 | $mode = $this->append ? 'a' : 'w';
99 | $this->fp = fopen($file, $mode);
100 | if ($this->fp === false) {
101 | $this->warn("Failed opening target file. Closing appender.");
102 | $this->fp = null;
103 | $this->closed = true;
104 | return false;
105 | }
106 |
107 | // Required when appending with concurrent access
108 | if($this->append) {
109 | fseek($this->fp, 0, SEEK_END);
110 | }
111 |
112 | // Write the header
113 | $this->write($this->layout->getHeader());
114 | }
115 |
116 | /**
117 | * Writes a string to the target file. Opens file if not already open.
118 | * @param string $string Data to write.
119 | */
120 | protected function write($string) {
121 | // Lazy file open
122 | if(!isset($this->fp)) {
123 | if ($this->openFile() === false) {
124 | return; // Do not write if file open failed.
125 | }
126 | }
127 |
128 | if ($this->locking) {
129 | $this->writeWithLocking($string);
130 | } else {
131 | $this->writeWithoutLocking($string);
132 | }
133 | }
134 |
135 | protected function writeWithLocking($string) {
136 | if(flock($this->fp, LOCK_EX)) {
137 | if(fwrite($this->fp, $string) === false) {
138 | $this->warn("Failed writing to file. Closing appender.");
139 | $this->closed = true;
140 | }
141 | flock($this->fp, LOCK_UN);
142 | } else {
143 | $this->warn("Failed locking file for writing. Closing appender.");
144 | $this->closed = true;
145 | }
146 | }
147 |
148 | protected function writeWithoutLocking($string) {
149 | if(fwrite($this->fp, $string) === false) {
150 | $this->warn("Failed writing to file. Closing appender.");
151 | $this->closed = true;
152 | }
153 | }
154 |
155 | public function activateOptions() {
156 | if (empty($this->file)) {
157 | $this->warn("Required parameter 'file' not set. Closing appender.");
158 | $this->closed = true;
159 | return;
160 | }
161 | }
162 |
163 | public function close() {
164 | if (is_resource($this->fp)) {
165 | $this->write($this->layout->getFooter());
166 | fclose($this->fp);
167 | }
168 | $this->fp = null;
169 | $this->closed = true;
170 | }
171 |
172 | public function append(LoggerLoggingEvent $event) {
173 | $this->write($this->layout->format($event));
174 | }
175 |
176 | /**
177 | * Sets the 'file' parameter.
178 | * @param string $file
179 | */
180 | public function setFile($file) {
181 | $this->setString('file', $file);
182 | }
183 |
184 | /**
185 | * Returns the 'file' parameter.
186 | * @return string
187 | */
188 | public function getFile() {
189 | return $this->file;
190 | }
191 |
192 | /**
193 | * Returns the 'append' parameter.
194 | * @return boolean
195 | */
196 | public function getAppend() {
197 | return $this->append;
198 | }
199 |
200 | /**
201 | * Sets the 'append' parameter.
202 | * @param boolean $append
203 | */
204 | public function setAppend($append) {
205 | $this->setBoolean('append', $append);
206 | }
207 |
208 | /**
209 | * Sets the 'file' parmeter. Left for legacy reasons.
210 | * @param string $fileName
211 | * @deprecated Use setFile() instead.
212 | */
213 | public function setFileName($fileName) {
214 | $this->setFile($fileName);
215 | }
216 |
217 | /**
218 | * Returns the 'file' parmeter. Left for legacy reasons.
219 | * @return string
220 | * @deprecated Use getFile() instead.
221 | */
222 | public function getFileName() {
223 | return $this->getFile();
224 | }
225 | }
226 |
--------------------------------------------------------------------------------
/web/log4php/appenders/LoggerAppenderFirePHP.php:
--------------------------------------------------------------------------------
1 | console = FirePHP::to($this->target)->console();
59 | $this->closed = false;
60 | } else {
61 | $this->warn('FirePHP is not installed correctly. Closing appender.');
62 | }
63 | }
64 |
65 | public function append(LoggerLoggingEvent $event) {
66 | $msg = $event->getMessage();
67 |
68 | // Skip formatting for objects and arrays which are handled by FirePHP.
69 | if (!is_array($msg) && !is_object($msg)) {
70 | $msg = $this->getLayout()->format($event);
71 | }
72 |
73 | switch ($event->getLevel()->toInt()) {
74 | case LoggerLevel::TRACE:
75 | case LoggerLevel::DEBUG:
76 | $this->console->log($msg);
77 | break;
78 | case LoggerLevel::INFO:
79 | $this->console->info($msg);
80 | break;
81 | case LoggerLevel::WARN:
82 | $this->console->warn($msg);
83 | break;
84 | case LoggerLevel::ERROR:
85 | case LoggerLevel::FATAL:
86 | $this->console->error($msg);
87 | break;
88 | }
89 | }
90 |
91 | /** Returns the target. */
92 | public function getTarget() {
93 | return $this->target;
94 | }
95 |
96 | /** Sets the target. */
97 | public function setTarget($target) {
98 | $this->setString('target', $target);
99 | }
100 | }
--------------------------------------------------------------------------------
/web/log4php/appenders/LoggerAppenderMail.php:
--------------------------------------------------------------------------------
1 | layout !== null) {
78 | $this->body .= $this->layout->format($event);
79 | }
80 | }
81 |
82 | public function close() {
83 | if($this->closed != true) {
84 | $from = $this->from;
85 | $to = $this->to;
86 |
87 | if(!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) {
88 | $subject = $this->subject;
89 | if(!$this->dry) {
90 | mail(
91 | $to, $subject,
92 | $this->layout->getHeader() . $this->body . $this->layout->getFooter(),
93 | "From: {$from}\r\n");
94 | } else {
95 | echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body;
96 | }
97 | }
98 | $this->closed = true;
99 | }
100 | }
101 |
102 | /** Sets the 'subject' parameter. */
103 | public function setSubject($subject) {
104 | $this->setString('subject', $subject);
105 | }
106 |
107 | /** Returns the 'subject' parameter. */
108 | public function getSubject() {
109 | return $this->subject;
110 | }
111 |
112 | /** Sets the 'to' parameter. */
113 | public function setTo($to) {
114 | $this->setString('to', $to);
115 | }
116 |
117 | /** Returns the 'to' parameter. */
118 | public function getTo() {
119 | return $this->to;
120 | }
121 |
122 | /** Sets the 'from' parameter. */
123 | public function setFrom($from) {
124 | $this->setString('from', $from);
125 | }
126 |
127 | /** Returns the 'from' parameter. */
128 | public function getFrom() {
129 | return $this->from;
130 | }
131 |
132 | /** Enables or disables dry mode. */
133 | public function setDry($dry) {
134 | $this->setBoolean('dry', $dry);
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/web/log4php/appenders/LoggerAppenderMailEvent.php:
--------------------------------------------------------------------------------
1 | to)) {
84 | $this->warn("Required parameter 'to' not set. Closing appender.");
85 | $this->close = true;
86 | return;
87 | }
88 |
89 | $sendmail_from = ini_get('sendmail_from');
90 | if (empty($this->from) and empty($sendmail_from)) {
91 | $this->warn("Required parameter 'from' not set. Closing appender.");
92 | $this->close = true;
93 | return;
94 | }
95 |
96 | $this->closed = false;
97 | }
98 |
99 | public function append(LoggerLoggingEvent $event) {
100 | $smtpHost = $this->smtpHost;
101 | $prevSmtpHost = ini_get('SMTP');
102 | if(!empty($smtpHost)) {
103 | ini_set('SMTP', $smtpHost);
104 | }
105 |
106 | $smtpPort = $this->port;
107 | $prevSmtpPort= ini_get('smtp_port');
108 | if($smtpPort > 0 and $smtpPort < 65535) {
109 | ini_set('smtp_port', $smtpPort);
110 | }
111 |
112 | // On unix only sendmail_path, which is PHP_INI_SYSTEM i.e. not changeable here, is used.
113 |
114 | $addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n";
115 |
116 | if(!$this->dry) {
117 | $result = mail($this->to, $this->subject, $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), $addHeader);
118 | } else {
119 | echo "DRY MODE OF MAIL APP.: Send mail to: ".$this->to." with additional headers '".trim($addHeader)."' and content: ".$this->layout->format($event);
120 | }
121 |
122 | ini_set('SMTP', $prevSmtpHost);
123 | ini_set('smtp_port', $prevSmtpPort);
124 | }
125 |
126 | /** Sets the 'from' parameter. */
127 | public function setFrom($from) {
128 | $this->setString('from', $from);
129 | }
130 |
131 | /** Returns the 'from' parameter. */
132 | public function getFrom() {
133 | return $this->from;
134 | }
135 |
136 | /** Sets the 'port' parameter. */
137 | public function setPort($port) {
138 | $this->setPositiveInteger('port', $port);
139 | }
140 |
141 | /** Returns the 'port' parameter. */
142 | public function getPort() {
143 | return $this->port;
144 | }
145 |
146 | /** Sets the 'smtpHost' parameter. */
147 | public function setSmtpHost($smtpHost) {
148 | $this->setString('smtpHost', $smtpHost);
149 | }
150 |
151 | /** Returns the 'smtpHost' parameter. */
152 | public function getSmtpHost() {
153 | return $this->smtpHost;
154 | }
155 |
156 | /** Sets the 'subject' parameter. */
157 | public function setSubject($subject) {
158 | $this->setString('subject', $subject);
159 | }
160 |
161 | /** Returns the 'subject' parameter. */
162 | public function getSubject() {
163 | return $this->subject;
164 | }
165 |
166 | /** Sets the 'to' parameter. */
167 | public function setTo($to) {
168 | $this->setString('to', $to);
169 | }
170 |
171 | /** Returns the 'to' parameter. */
172 | public function getTo() {
173 | return $this->to;
174 | }
175 |
176 | /** Enables or disables dry mode. */
177 | public function setDry($dry) {
178 | $this->setBoolean('dry', $dry);
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/web/log4php/appenders/LoggerAppenderNull.php:
--------------------------------------------------------------------------------
1 | level < WARN mapped to E_USER_NOTICE
28 | * - WARN <= level < ERROR mapped to E_USER_WARNING
29 | * - level >= ERROR mapped to E_USER_ERROR
30 | *
31 | * @version $Revision: 1337820 $
32 | * @package log4php
33 | * @subpackage appenders
34 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
35 | * @link http://logging.apache.org/log4php/docs/appenders/php.html Appender documentation
36 | */
37 | class LoggerAppenderPhp extends LoggerAppender {
38 |
39 | public function append(LoggerLoggingEvent $event) {
40 | $level = $event->getLevel();
41 | if($level->isGreaterOrEqual(LoggerLevel::getLevelError())) {
42 | trigger_error($this->layout->format($event), E_USER_ERROR);
43 | } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) {
44 | trigger_error($this->layout->format($event), E_USER_WARNING);
45 | } else {
46 | trigger_error($this->layout->format($event), E_USER_NOTICE);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/web/log4php/appenders/LoggerAppenderSocket.php:
--------------------------------------------------------------------------------
1 | remoteHost)) {
62 | $this->warn("Required parameter [remoteHost] not set. Closing appender.");
63 | $this->closed = true;
64 | return;
65 | }
66 |
67 | if (empty($this->timeout)) {
68 | $this->timeout = ini_get("default_socket_timeout");
69 | }
70 |
71 | $this->closed = false;
72 | }
73 |
74 | public function append(LoggerLoggingEvent $event) {
75 | $socket = fsockopen($this->remoteHost, $this->port, $errno, $errstr, $this->timeout);
76 | if ($socket === false) {
77 | $this->warn("Could not open socket to {$this->remoteHost}:{$this->port}. Closing appender.");
78 | $this->closed = true;
79 | return;
80 | }
81 |
82 | if (false === fwrite($socket, $this->layout->format($event))) {
83 | $this->warn("Error writing to socket. Closing appender.");
84 | $this->closed = true;
85 | }
86 | fclose($socket);
87 | }
88 |
89 | // ******************************************
90 | // *** Accessor methods ***
91 | // ******************************************
92 |
93 | /** Sets the target host. */
94 | public function setRemoteHost($hostname) {
95 | $this->setString('remoteHost', $hostname);
96 | }
97 |
98 | /** Sets the target port */
99 | public function setPort($port) {
100 | $this->setPositiveInteger('port', $port);
101 | }
102 |
103 | /** Sets the timeout. */
104 | public function setTimeout($timeout) {
105 | $this->setPositiveInteger('timeout', $timeout);
106 | }
107 |
108 | /** Returns the target host. */
109 | public function getRemoteHost() {
110 | return $this->getRemoteHost();
111 | }
112 |
113 | /** Returns the target port. */
114 | public function getPort() {
115 | return $this->port;
116 | }
117 |
118 | /** Returns the timeout */
119 | public function getTimeout() {
120 | return $this->timeout;
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/web/log4php/configurators/LoggerConfigurationAdapter.php:
--------------------------------------------------------------------------------
1 |
28 | * array(
31 | * 'level' => 'info',
32 | * 'appenders' => array('default')
33 | * ),
34 | * 'appenders' => array(
35 | * 'default' => array(
36 | * 'class' => 'LoggerAppenderEcho',
37 | * 'layout' => array(
38 | * 'class' => 'LoggerLayoutSimple'
39 | * )
40 | * )
41 | * )
42 | * )
43 | * ?>
44 | *
45 | *
46 | * @package log4php
47 | * @subpackage configurators
48 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
49 | * @version $Revision: 1343601 $
50 | * @since 2.2
51 | */
52 | class LoggerConfigurationAdapterPHP implements LoggerConfigurationAdapter
53 | {
54 | public function convert($url) {
55 | if (!file_exists($url)) {
56 | throw new LoggerException("File [$url] does not exist.");
57 | }
58 |
59 | // Load the config file
60 | $data = @file_get_contents($url);
61 | if ($data === false) {
62 | $error = error_get_last();
63 | throw new LoggerException("Error loading config file: {$error['message']}");
64 | }
65 |
66 | $config = @eval('?>' . $data);
67 |
68 | if ($config === false) {
69 | $error = error_get_last();
70 | throw new LoggerException("Error parsing configuration: " . $error['message']);
71 | }
72 |
73 | if (empty($config)) {
74 | throw new LoggerException("Invalid configuration: empty configuration array.");
75 | }
76 |
77 | if (!is_array($config)) {
78 | throw new LoggerException("Invalid configuration: not an array.");
79 | }
80 |
81 | return $config;
82 | }
83 | }
84 |
85 |
--------------------------------------------------------------------------------
/web/log4php/filters/LoggerFilterDenyAll.php:
--------------------------------------------------------------------------------
1 |
30 | * An example for this filter:
31 | *
32 | * {@example ../../examples/php/filter_denyall.php 19}
33 | *
34 | *
30 | *
31 | * {@example ../../examples/resources/layout_simple.properties 18}
32 | *
33 | * would result in:
34 | *
35 | * INFO - Hello World!
36 | *
37 | * @version $Revision: 1213283 $
38 | * @package log4php
39 | * @subpackage layouts
40 | */
41 | class LoggerLayoutSimple extends LoggerLayout {
42 | /**
43 | * Returns the log statement in a format consisting of the
44 | * level, followed by " - " and then the
45 | * message. For example,
46 | * INFO - "A message"
47 | *
48 | * @param LoggerLoggingEvent $event
49 | * @return string
50 | */
51 | public function format(LoggerLoggingEvent $event) {
52 | $level = $event->getLevel();
53 | $message = $event->getRenderedMessage();
54 | return "$level - $message" . PHP_EOL;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/web/log4php/layouts/LoggerLayoutTTCC.php:
--------------------------------------------------------------------------------
1 | time, thread, category and nested
23 | * diagnostic context information, hence the name.
24 | *
25 | *
41 | *
42 | * {@example ../../examples/resources/layout_ttcc.properties 18}
43 | *
44 | * The above would print:
45 | * 02:28 [13714] INFO root - Hello World!
46 | *
47 | * @version $Revision: 1302503 $
48 | * @package log4php
49 | * @subpackage layouts
50 | *
51 | * @deprecated LoggerLayout TTCC is deprecated and will be removed in a future release. Please use
52 | * LoggerLayoutPattern instead.
53 | */
54 | class LoggerLayoutTTCC extends LoggerLayout {
55 |
56 | // Internal representation of options
57 | protected $threadPrinting = true;
58 | protected $categoryPrefixing = true;
59 | protected $contextPrinting = true;
60 | protected $microSecondsPrinting = true;
61 |
62 | /**
63 | * @var string date format. See {@link PHP_MANUAL#strftime} for details
64 | */
65 | protected $dateFormat = '%c';
66 |
67 | /**
68 | * Constructor
69 | *
70 | * @param string date format
71 | * @see dateFormat
72 | */
73 | public function __construct($dateFormat = '') {
74 | $this->warn("LoggerLayout TTCC is deprecated and will be removed in a future release. Please use LoggerLayoutPattern instead.");
75 | if (!empty($dateFormat)) {
76 | $this->dateFormat = $dateFormat;
77 | }
78 | return;
79 | }
80 |
81 | /**
82 | * The ThreadPrinting option specifies whether the name of the
83 | * current thread is part of log output or not. This is true by default.
84 | */
85 | public function setThreadPrinting($threadPrinting) {
86 | $this->setBoolean('threadPrinting', $threadPrinting);
87 | }
88 |
89 | /**
90 | * @return boolean Returns value of the ThreadPrinting option.
91 | */
92 | public function getThreadPrinting() {
93 | return $this->threadPrinting;
94 | }
95 |
96 | /**
97 | * The CategoryPrefixing option specifies whether {@link Category}
98 | * name is part of log output or not. This is true by default.
99 | */
100 | public function setCategoryPrefixing($categoryPrefixing) {
101 | $this->setBoolean('categoryPrefixing', $categoryPrefixing);
102 | }
103 |
104 | /**
105 | * @return boolean Returns value of the CategoryPrefixing option.
106 | */
107 | public function getCategoryPrefixing() {
108 | return $this->categoryPrefixing;
109 | }
110 |
111 | /**
112 | * The ContextPrinting option specifies log output will include
113 | * the nested context information belonging to the current thread.
114 | * This is true by default.
115 | */
116 | public function setContextPrinting($contextPrinting) {
117 | $this->setBoolean('contextPrinting', $contextPrinting);
118 | }
119 |
120 | /**
121 | * @return boolean Returns value of the ContextPrinting option.
122 | */
123 | public function getContextPrinting() {
124 | return $this->contextPrinting;
125 | }
126 |
127 | /**
128 | * The MicroSecondsPrinting option specifies if microseconds infos
129 | * should be printed at the end of timestamp.
130 | * This is true by default.
131 | */
132 | public function setMicroSecondsPrinting($microSecondsPrinting) {
133 | $this->setBoolean('microSecondsPrinting', $microSecondsPrinting);
134 | }
135 |
136 | /**
137 | * @return boolean Returns value of the MicroSecondsPrinting option.
138 | */
139 | public function getMicroSecondsPrinting() {
140 | return $this->microSecondsPrinting;
141 | }
142 |
143 |
144 | public function setDateFormat($dateFormat) {
145 | $this->setString('dateFormat', $dateFormat);
146 | }
147 |
148 | /**
149 | * @return string
150 | */
151 | public function getDateFormat() {
152 | return $this->dateFormat;
153 | }
154 |
155 | /**
156 | * In addition to the level of the statement and message, the
157 | * returned string includes time, thread, category.
158 | *
38 | *
39 | * {@example ../../examples/resources/layout_xml.properties 18}
40 | *
41 | * The above would print:
42 | *
43 | *
44 | *
51 | *
52 | * @version $Revision: 1213283 $
53 | * @package log4php
54 | * @subpackage layouts
55 | */
56 | class LoggerLayoutXml extends LoggerLayout {
57 | const LOG4J_NS_PREFIX ='log4j';
58 | const LOG4J_NS = 'http://jakarta.apache.org/log4j/';
59 |
60 | const LOG4PHP_NS_PREFIX = 'log4php';
61 | const LOG4PHP_NS = 'http://logging.apache.org/log4php/';
62 |
63 | const CDATA_START = '';
65 | const CDATA_PSEUDO_END = ']]>';
66 | const CDATA_EMBEDDED_END = ']]>]]>getLog4jNamespace()) {
90 | $this->namespace = self::LOG4J_NS;
91 | $this->namespacePrefix = self::LOG4J_NS_PREFIX;
92 | } else {
93 | $this->namespace = self::LOG4PHP_NS;
94 | $this->namespacePrefix = self::LOG4PHP_NS_PREFIX;
95 | }
96 | }
97 |
98 | /**
99 | * @return string
100 | */
101 | public function getHeader() {
102 | return "<{$this->namespacePrefix}:eventSet ".
103 | "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ".
104 | "version=\"0.3\" ".
105 | "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"".
106 | ">" . PHP_EOL;
107 | }
108 |
109 | /**
110 | * Formats a {@link LoggerLoggingEvent} in conformance with the log4php.dtd.
111 | *
112 | * @param LoggerLoggingEvent $event
113 | * @return string
114 | */
115 | public function format(LoggerLoggingEvent $event) {
116 | $ns = $this->namespacePrefix;
117 |
118 | $loggerName = $event->getLoggerName();
119 | $timeStamp = number_format((float)($event->getTimeStamp() * 1000), 0, '', '');
120 | $thread = $event->getThreadName();
121 | $level = $event->getLevel()->toString();
122 |
123 | $buf = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL;
124 | $buf .= "<$ns:message>";
125 | $buf .= $this->encodeCDATA($event->getRenderedMessage());
126 | $buf .= "$ns:message>".PHP_EOL;
127 |
128 | $ndc = $event->getNDC();
129 | if(!empty($ndc)) {
130 | $buf .= "<$ns:NDC>encodeCDATA($ndc);
132 | $buf .= "]]>$ns:NDC>".PHP_EOL;
133 | }
134 |
135 | $mdcMap = $event->getMDCMap();
136 | if (!empty($mdcMap)) {
137 | $buf .= "<$ns:properties>".PHP_EOL;
138 | foreach ($mdcMap as $name=>$value) {
139 | $buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL;
140 | }
141 | $buf .= "$ns:properties>".PHP_EOL;
142 | }
143 |
144 | if ($this->getLocationInfo()) {
145 | $locationInfo = $event->getLocationInformation();
146 | $buf .= "<$ns:locationInfo ".
147 | "class=\"" . $locationInfo->getClassName() . "\" ".
148 | "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ".
149 | "line=\"" . $locationInfo->getLineNumber() . "\" ".
150 | "method=\"" . $locationInfo->getMethodName() . "\" ";
151 | $buf .= "/>".PHP_EOL;
152 | }
153 |
154 | $buf .= "$ns:event>".PHP_EOL;
155 |
156 | return $buf;
157 | }
158 |
159 | /**
160 | * @return string
161 | */
162 | public function getFooter() {
163 | return "{$this->namespacePrefix}:eventSet>" . PHP_EOL;
164 | }
165 |
166 |
167 | /**
168 | * Whether or not file name and line number will be included in the output.
169 | * @return boolean
170 | */
171 | public function getLocationInfo() {
172 | return $this->locationInfo;
173 | }
174 |
175 | /**
176 | * The {@link $locationInfo} option takes a boolean value. By default,
177 | * it is set to false which means there will be no location
178 | * information output by this layout. If the the option is set to
179 | * true, then the file name and line number of the statement at the
180 | * origin of the log statement will be output.
181 | */
182 | public function setLocationInfo($flag) {
183 | $this->setBoolean('locationInfo', $flag);
184 | }
185 |
186 | /**
187 | * @return boolean
188 | */
189 | public function getLog4jNamespace() {
190 | return $this->log4jNamespace;
191 | }
192 |
193 | /**
194 | * @param boolean
195 | */
196 | public function setLog4jNamespace($flag) {
197 | $this->setBoolean('log4jNamespace', $flag);
198 | }
199 |
200 | /**
201 | * Encases a string in CDATA tags, and escapes any existing CDATA end
202 | * tags already present in the string.
203 | * @param string $string
204 | */
205 | private function encodeCDATA($string) {
206 | $string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string);
207 | return self::CDATA_START . $string . self::CDATA_END;
208 | }
209 | }
210 |
211 |
--------------------------------------------------------------------------------
/web/log4php/pattern/LoggerPatternConverter.php:
--------------------------------------------------------------------------------
1 | Conversion specifiers in a conversion patterns are parsed to
26 | * individual PatternConverters. Each of which is responsible for
27 | * converting a logging event in a converter specific manner.