|
16 | 16 | */
|
17 | 17 |
|
18 | 18 | #include "php.h"
|
| 19 | +#include "php_time.h" |
19 | 20 | #include "mysqlnd.h"
|
20 | 21 | #include "mysqlnd_priv.h"
|
21 | 22 | #include "mysqlnd_debug.h"
|
@@ -76,21 +77,19 @@ MYSQLND_METHOD(mysqlnd_debug, log)(MYSQLND_DEBUG * self,
|
76 | 77 | }
|
77 | 78 | if (flags & MYSQLND_DEBUG_DUMP_TIME) {
|
78 | 79 | /* The following from FF's DBUG library, which is in the public domain */
|
79 | | - struct timevaltv; |
| 80 | + struct timespects; |
80 | 81 | struct tm *tm_p;
|
81 | | - if (gettimeofday(&tv, NULL) != -1) { |
82 | | - const time_t sec = tv.tv_sec; |
83 | | - if ((tm_p = localtime((const time_t *)&sec))) { |
84 | | - snprintf(time_buffer, sizeof(time_buffer) - 1, |
85 | | - /* "%04d-%02d-%02d " */ |
86 | | - "%02d:%02d:%02d.%06d ", |
87 | | - /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/ |
88 | | - tm_p->tm_hour, tm_p->tm_min, tm_p->tm_sec, |
89 | | - (int) (tv.tv_usec)); |
90 | | - time_buffer[sizeof(time_buffer) - 1 ] = '0円'; |
91 | | - } else { |
92 | | - time_buffer[0] = '0円'; |
93 | | - } |
| 82 | + php_realtime_spec(&ts); |
| 83 | + if ((tm_p = localtime((const time_t *)&ts.tv_sec))) { |
| 84 | + snprintf(time_buffer, sizeof(time_buffer) - 1, |
| 85 | + /* "%04d-%02d-%02d " */ |
| 86 | + "%02d:%02d:%02d.%06d ", |
| 87 | + /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/ |
| 88 | + tm_p->tm_hour, tm_p->tm_min, tm_p->tm_sec, |
| 89 | + (int) (ts.tv_nsec / 1000)); |
| 90 | + time_buffer[sizeof(time_buffer) - 1 ] = '0円'; |
| 91 | + } else { |
| 92 | + time_buffer[0] = '0円'; |
94 | 93 | }
|
95 | 94 | }
|
96 | 95 | if (flags & MYSQLND_DEBUG_DUMP_FILE) {
|
@@ -163,21 +162,19 @@ MYSQLND_METHOD(mysqlnd_debug, log_va)(MYSQLND_DEBUG *self,
|
163 | 162 | }
|
164 | 163 | if (flags & MYSQLND_DEBUG_DUMP_TIME) {
|
165 | 164 | /* The following from FF's DBUG library, which is in the public domain */
|
166 | | - struct timevaltv; |
| 165 | + struct timespects; |
167 | 166 | struct tm *tm_p;
|
168 | | - if (gettimeofday(&tv, NULL) != -1) { |
169 | | - const time_t sec = tv.tv_sec; |
170 | | - if ((tm_p = localtime((const time_t *)&sec))) { |
171 | | - snprintf(time_buffer, sizeof(time_buffer) - 1, |
172 | | - /* "%04d-%02d-%02d " */ |
173 | | - "%02d:%02d:%02d.%06d ", |
174 | | - /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/ |
175 | | - tm_p->tm_hour, tm_p->tm_min, tm_p->tm_sec, |
176 | | - (int) (tv.tv_usec)); |
177 | | - time_buffer[sizeof(time_buffer) - 1 ] = '0円'; |
178 | | - } else { |
179 | | - time_buffer[0] = '0円'; |
180 | | - } |
| 167 | + php_realtime_spec(&ts); |
| 168 | + if ((tm_p = localtime((const time_t *)&ts.tv_sec))) { |
| 169 | + snprintf(time_buffer, sizeof(time_buffer) - 1, |
| 170 | + /* "%04d-%02d-%02d " */ |
| 171 | + "%02d:%02d:%02d.%06d ", |
| 172 | + /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/ |
| 173 | + tm_p->tm_hour, tm_p->tm_min, tm_p->tm_sec, |
| 174 | + (int)(ts.tv_nsec / 1000)); |
| 175 | + time_buffer[sizeof(time_buffer) - 1 ] = '0円'; |
| 176 | + } else { |
| 177 | + time_buffer[0] = '0円'; |
181 | 178 | }
|
182 | 179 | }
|
183 | 180 | if (flags & MYSQLND_DEBUG_DUMP_FILE) {
|
@@ -329,8 +326,8 @@ MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int lin
|
329 | 326 | uint64_t own_time = call_time - mine_non_own_time;
|
330 | 327 | uint32_t func_name_len = strlen(*func_name);
|
331 | 328 |
|
332 | | - self->m->log_va(self, line, file, zend_stack_count(&self->call_stack) - 1, NULL, "<%s (total=%u own=%u in_calls=%u)", |
333 | | - *func_name, (unsigned int) call_time, (unsigned int) own_time, (unsigned int) mine_non_own_time |
| 329 | + self->m->log_va(self, line, file, zend_stack_count(&self->call_stack) - 1, NULL, "<%s (total=%"PRIu64" own=%"PRIu64" in_calls=%"PRIu64")", |
| 330 | + *func_name, call_time, own_time, mine_non_own_time |
334 | 331 | );
|
335 | 332 |
|
336 | 333 | if ((f_profile = zend_hash_str_find_ptr(&self->function_profiles, *func_name, func_name_len)) != NULL) {
|
|
0 commit comments