source: branches/feature-module-paygent/data/downloads/module/mdl_paygent/jp/co/ks/merchanttool/connectmodule/util/PaygentB2BModuleLogger.php @ 15162

Revision 15162, 3.9 KB checked in by naka, 17 years ago (diff)

ペイジェント決済モジュール

Line 
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
10define('LOG4PHP_DIR', 'log4php');
11require_once(LOG4PHP_DIR . '/LoggerManager.php');
12require_once(LOG4PHP_DIR . '/layouts/LoggerPatternLayout.php');
13require_once(LOG4PHP_DIR . '/appenders/LoggerAppenderFile.php');
14
15include_once("jp/co/ks/merchanttool/connectmodule/exception/PaygentB2BModuleException.php");
16include_once("jp/co/ks/merchanttool/connectmodule/system/PaygentB2BModuleResources.php");
17
18/**
19 * Ú‘±ƒ‚ƒWƒ…[ƒ‹—p Logger ƒNƒ‰ƒX
20 *
21 * @version $Revision: 1.4 $
22 * @author $Author: t-mori $
23 */
24
25    /** Logo—̓pƒ^[ƒ“•¶Žš—ñ */
26    define("PaygentB2BModuleLogger__PATTERN", "%d{Y/m/d H:i:s} %-5p %c %m%n");
27
28
29class PaygentB2BModuleLogger {
30
31    /** logger•ÛŽ */
32    //var $instance = null;
33
34    /** FileAppender •ÛŽ */
35    var $appender = null;
36
37    /**
38     * ƒRƒ“ƒXƒgƒ‰ƒNƒ^
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     * ƒfƒoƒbƒOƒƒO‚ðo—Í
79     *
80     * @param className String ƒƒO‚̏o—ÍŒ³ƒNƒ‰ƒX–¼ o—ÍŒ³‚ðŽ¯•Ê
81     * @param message Object ƒƒOƒƒbƒZ[ƒ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     * ƒCƒ“ƒtƒHƒƒO‚ðo—Í
93     *
94     * @param className String ƒƒO‚̏o—ÍŒ³ƒNƒ‰ƒX–¼ o—ÍŒ³‚ðŽ¯•Ê
95     * @param message Object ƒƒOƒƒbƒZ[ƒ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     * ƒ[ƒjƒ“ƒOƒƒO‚ðo—Í
107     *
108     * @param className String ƒƒO‚̏o—ÍŒ³ƒNƒ‰ƒX–¼ o—ÍŒ³‚ðŽ¯•Ê
109     * @param message Object ƒƒOƒƒbƒZ[ƒ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—ÍŒ³ƒNƒ‰ƒX–¼ o—ÍŒ³‚ðŽ¯•Ê
123     * @param messageObject ƒƒOƒƒbƒZ[ƒ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     * ƒtƒF[ƒ^ƒ‹ƒƒO‚ðo—Í
135     *
136     * @param className String ƒƒO‚̏o—ÍŒ³ƒNƒ‰ƒX–¼ o—ÍŒ³‚ðŽ¯•Ê
137     * @param message Object ƒƒOƒƒbƒZ[ƒ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?>
Note: See TracBrowser for help on using the repository browser.