MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / DoPrefix

Function DoPrefix

dbug/dbug.c:2013–2059  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2011 */
2012
2013static void DoPrefix(CODE_STATE *cs, uint _line_)
2014{
2015 cs->lineno++;
2016 if (cs->stack->flags & PID_ON)
2017 {
2018 (void) fprintf(cs->stack->out_file, "%-7s: ", my_thread_name());
2019 }
2020 if (cs->stack->flags & NUMBER_ON)
2021 (void) fprintf(cs->stack->out_file, "%5d: ", cs->lineno);
2022 if (cs->stack->flags & TIMESTAMP_ON)
2023 {
2024#ifdef __WIN__
2025 /* FIXME This doesn't give microseconds as in Unix case, and the resolution is
2026 in system ticks, 10 ms intervals. See my_getsystime.c for high res */
2027 SYSTEMTIME loc_t;
2028 GetLocalTime(&loc_t);
2029 (void) fprintf (cs->stack->out_file,
2030 /* "%04d-%02d-%02d " */
2031 "%02d:%02d:%02d.%06d ",
2032 /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/
2033 loc_t.wHour, loc_t.wMinute, loc_t.wSecond, loc_t.wMilliseconds);
2034#else
2035 struct timeval tv;
2036 struct tm *tm_p;
2037 if (gettimeofday(&tv, NULL) != -1)
2038 {
2039 if ((tm_p= localtime((const time_t *)&tv.tv_sec)))
2040 {
2041 (void) fprintf (cs->stack->out_file,
2042 /* "%04d-%02d-%02d " */
2043 "%02d:%02d:%02d.%06d ",
2044 /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/
2045 tm_p->tm_hour, tm_p->tm_min, tm_p->tm_sec,
2046 (int) (tv.tv_usec));
2047 }
2048 }
2049#endif
2050 }
2051 if (cs->stack->flags & PROCESS_ON)
2052 (void) fprintf(cs->stack->out_file, "%s: ", cs->process);
2053 if (cs->stack->flags & FILE_ON)
2054 (void) fprintf(cs->stack->out_file, "%14s: ", BaseName(cs->file));
2055 if (cs->stack->flags & LINE_ON)
2056 (void) fprintf(cs->stack->out_file, "%5d: ", _line_);
2057 if (cs->stack->flags & DEPTH_ON)
2058 (void) fprintf(cs->stack->out_file, "%4d: ", cs->level);
2059}
2060
2061
2062/*

Callers 4

_db_enter_Function · 0.85
_db_return_Function · 0.85
_db_doprnt_Function · 0.85
_db_dump_Function · 0.85

Calls 2

my_thread_nameFunction · 0.85
BaseNameFunction · 0.85

Tested by

no test coverage detected