GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( ee2d44...c597f0 )
by やかみ
03:11
created

Log   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 28.57%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 55
ccs 6
cts 21
cp 0.2857
rs 10
wmc 7
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A normal() 0 4 1
A sql() 0 4 1
B write() 0 23 5
1
<?php
2
/**
3
 * Kotori.php
4
 *
5
 * A Tiny Model-View-Controller PHP Framework
6
 *
7
 * This content is released under the Apache 2 License
8
 *
9
 * Copyright (c) 2015-2017 Kotori Technology. All rights reserved.
10
 *
11
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14
 *
15
 *     http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22
 */
23
24
/**
25
 * Logging Class
26
 *
27
 * @package     Kotori
28
 * @subpackage  Debug
29
 * @author      Kokororin
30
 * @link        https://kotori.love
31
 */
32
namespace Kotori\Debug;
33
34
use Kotori\Core\Helper;
35
use Kotori\Facade\Config;
36
37
abstract class Log
38
{
39
    /**
40
     * Write Log File
41
     *
42
     * Support Sina App Engine
43
     *
44
     * @param  string $msg
45
     * @param  string $level
46
     * @return void
47
     */
48 4
    protected static function write($msg, $level = '')
49
    {
50 4
        if (!Config::get('APP_DEBUG')) {
51 4
            return;
52
        }
53
54
        if (function_exists('saeAutoLoader')) {
55
            $msg = "[{$level}]" . $msg;
56
            sae_set_display_errors(false);
57
            sae_debug(trim($msg));
58
            sae_set_display_errors(true);
59
        } else {
60
            $msg = date('[Y-m-d H:i:s]') . "\r\n" . "[{$level}]" . "\r\n" . $msg . "\r\n\r\n";
61
            $logPath = Config::get('APP_FULL_PATH') . '/logs';
62
            if (!file_exists($logPath)) {
63
                Helper::mkdirs($logPath);
64
            }
65
66
            if (file_exists($logPath)) {
67
                file_put_contents($logPath . '/' . date('Ymd') . '.log', $msg, FILE_APPEND);
68
            }
69
        }
70
    }
71
72
    /**
73
     * Write Normal Log
74
     *
75
     * @param string $msg
76
     */
77
    public static function normal($msg)
78
    {
79
        self::write($msg, 'NORMAL');
80
    }
81
82
    /**
83
     * Write SQL Log
84
     *
85
     * @param string $msg
86
     */
87 4
    public static function sql($msg)
88
    {
89 4
        self::write($msg, 'SQL');
90 4
    }
91
}
92