forked from xpressengine/xe-module-profiler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
profiler.controller.php
82 lines (71 loc) · 1.97 KB
/
profiler.controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* @class profilerController
* @author NAVER ([email protected])
* @brief Profiler module controller class.
*/
class profilerController extends profiler
{
function init()
{
}
/**
* @brief Slowlog 기록
* @param stdClass $args
* @return mixed
*/
function triggerWriteSlowlog($args)
{
$oProfilerModel = getModel('profiler');
$config = $oProfilerModel->getConfig();
// 슬로우 로그를 쓰지 않을경우 리턴
if($config->slowlog->enabled !== 'Y')
{
return new Object();
}
// 잘못된 인자 검사
if(!is_object($args))
{
$args = new stdClass();
}
if(($args->_log_type == 'trigger' || $args->_log_type == 'addon' || $args->_log_type == 'widget')
&& ($args->_elapsed_time < $config->slowlog->{'time_' . $args->_log_type}))
{
return new Object();
}
// hash id 생성
$type_hash_id = md5($args->caller . '@' . $args->called);
// type에 등록되어 있는지 확인
$cond = new stdClass();
$cond->hash_id = $type_hash_id;
$output = executeQuery('profiler.getSlowlogType', $cond);
// type에 등록되어 있지 않으면 추가
if(!$output->data)
{
$slowlog_type = new stdClass();
$slowlog_type->type = $args->_log_type;
$slowlog_type->hash_id = $type_hash_id;
$slowlog_type->caller = $args->caller;
$slowlog_type->called = $args->called;
$slowlog_type->called_extension = $args->called_extension;
$output = executeQuery('profiler.insertSlowlogType', $slowlog_type);
if(!$output->toBool())
{
return $output;
}
}
// 수행 시간을 기록
$slowlog = new stdClass();
$slowlog->type_hash_id = $type_hash_id;
$slowlog->elapsed_time = $args->_elapsed_time;
$slowlog->logged_timestamp = time();
$output = executeQuery('profiler.insertSlowlog', $slowlog);
if(!$output->toBool())
{
return $output;
}
}
}
/* End of file profiler.controller.php */
/* Location: ./modules/profiler/profiler.controller.php */