1 | <?php |
---|
2 | /** |
---|
3 | * PAYGENT B2B MODULE |
---|
4 | * PaygentB2BModuleLogger.php |
---|
5 | * |
---|
6 | * Copyright (C) 2007 by PAYGENT Co., Ltd. |
---|
7 | * All rights reserved. |
---|
8 | */ |
---|
9 | |
---|
10 | define('LOG4PHP_DIR', 'log4php'); |
---|
11 | require_once(LOG4PHP_DIR . '/LoggerManager.php'); |
---|
12 | require_once(LOG4PHP_DIR . '/layouts/LoggerPatternLayout.php'); |
---|
13 | require_once(LOG4PHP_DIR . '/appenders/LoggerAppenderFile.php'); |
---|
14 | |
---|
15 | include_once("jp/co/ks/merchanttool/connectmodule/exception/PaygentB2BModuleException.php"); |
---|
16 | include_once("jp/co/ks/merchanttool/connectmodule/system/PaygentB2BModuleResources.php"); |
---|
17 | |
---|
18 | /** |
---|
19 | * Ú±W
[p Logger NX |
---|
20 | * |
---|
21 | * @version $Revision: 1.4 $ |
---|
22 | * @author $Author: t-mori $ |
---|
23 | */ |
---|
24 | |
---|
25 | /** LogoÍp^[¶ñ */ |
---|
26 | define("PaygentB2BModuleLogger__PATTERN", "%d{Y/m/d H:i:s} %-5p %c %m%n"); |
---|
27 | |
---|
28 | |
---|
29 | class PaygentB2BModuleLogger { |
---|
30 | |
---|
31 | /** loggerÛ */ |
---|
32 | //var $instance = null; |
---|
33 | |
---|
34 | /** FileAppender Û */ |
---|
35 | var $appender = null; |
---|
36 | |
---|
37 | /** |
---|
38 | * RXgN^ |
---|
39 | */ |
---|
40 | function PaygentB2BModuleLogger() { |
---|
41 | $layout = new LoggerPatternLayout(); |
---|
42 | $layout->setConversionPattern(PaygentB2BModuleLogger__PATTERN); |
---|
43 | $layout->activateOptions(); |
---|
44 | $this->appender = new LoggerAppenderFile("FileLogger"); |
---|
45 | $this->appender->setLayout($layout); |
---|
46 | |
---|
47 | $inst = PaygentB2BModuleResources::getInstance(); |
---|
48 | if (is_object($inst) && |
---|
49 | !StringUtil::isEmpty($inst->getLogOutputPath())) { |
---|
50 | $this->appender->setFile($inst->getLogOutputPath(), true); |
---|
51 | $this->appender->activateOptions(); |
---|
52 | } else { |
---|
53 | $this->appender = null; |
---|
54 | trigger_error("Cannot get log file.", E_USER_WARNING); |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | /** |
---|
59 | * PaygentB2BModuleLogger ðæ¾ |
---|
60 | * |
---|
61 | * @return PaygentB2BModuleLogger |
---|
62 | */ |
---|
63 | function &getInstance() { |
---|
64 | static $logInstance = null; |
---|
65 | if (isset($logInstance) == false |
---|
66 | || $logInstance == null |
---|
67 | || is_object($logInstance) != true) { |
---|
68 | |
---|
69 | $logInstance = new PaygentB2BModuleLogger(); |
---|
70 | if ($logInstance->appender == null) { |
---|
71 | $logInstance = null; |
---|
72 | } |
---|
73 | } |
---|
74 | return $logInstance; |
---|
75 | } |
---|
76 | |
---|
77 | /** |
---|
78 | * fobOOðoÍ |
---|
79 | * |
---|
80 | * @param className String OÌoͳNX¼ oͳð¯Ê |
---|
81 | * @param message Object ObZ[W |
---|
82 | * @param throwable Throwable |
---|
83 | */ |
---|
84 | function debug($className, $message, $throwable = null) { |
---|
85 | $log = &LoggerManager::getLogger($className); |
---|
86 | $log->setLevel(LoggerLevel::getLevelDebug()); |
---|
87 | $log->addAppender($this->appender); |
---|
88 | $log->debug($message, $throwable); |
---|
89 | } |
---|
90 | |
---|
91 | /** |
---|
92 | * CtHOðoÍ |
---|
93 | * |
---|
94 | * @param className String OÌoͳNX¼ oͳð¯Ê |
---|
95 | * @param message Object ObZ[W |
---|
96 | * @param throwable Throwable |
---|
97 | */ |
---|
98 | function info($className, $message, $throwable = null) { |
---|
99 | $log = &LoggerManager::getLogger($className); |
---|
100 | $log->setLevel(LoggerLevel::getLevelDebug()); |
---|
101 | $log->addAppender($this->appender); |
---|
102 | $log->info($message, $throwable); |
---|
103 | } |
---|
104 | |
---|
105 | /** |
---|
106 | * [jOOðoÍ |
---|
107 | * |
---|
108 | * @param className String OÌoͳNX¼ oͳð¯Ê |
---|
109 | * @param message Object ObZ[W |
---|
110 | * @param throwable Throwable |
---|
111 | */ |
---|
112 | function warn($className, $message, $throwable = null) { |
---|
113 | $log = &LoggerManager::getLogger($className); |
---|
114 | $log->setLevel(LoggerLevel::getLevelDebug()); |
---|
115 | $log->addAppender($this->appender); |
---|
116 | $log->info($message, $throwable); |
---|
117 | } |
---|
118 | |
---|
119 | /** |
---|
120 | * G[OðoÍ |
---|
121 | * |
---|
122 | * @param className String OÌoͳNX¼ oͳð¯Ê |
---|
123 | * @param messageObject ObZ[W |
---|
124 | * @param throwable Throwable |
---|
125 | */ |
---|
126 | function error($className, $message, $throwable = null) { |
---|
127 | $log = &LoggerManager::getLogger($className); |
---|
128 | $log->setLevel(LoggerLevel::getLevelDebug()); |
---|
129 | $log->addAppender($this->appender); |
---|
130 | $log->error($message, $throwable); |
---|
131 | } |
---|
132 | |
---|
133 | /** |
---|
134 | * tF[^OðoÍ |
---|
135 | * |
---|
136 | * @param className String OÌoͳNX¼ oͳð¯Ê |
---|
137 | * @param message Object ObZ[W |
---|
138 | * @param throwable Throwable |
---|
139 | */ |
---|
140 | function fatal($className, $message, $throwable = null) { |
---|
141 | $log = &LoggerManager::getLogger($className); |
---|
142 | $log->setLevel(LoggerLevel::getLevelDebug()); |
---|
143 | $log->addAppender($this->appender); |
---|
144 | $log->fatal($message, $throwable); |
---|
145 | } |
---|
146 | |
---|
147 | } |
---|
148 | |
---|
149 | ?> |
---|