Blame view

src/decoder/gb28181/sip/Utils/Log.h 842 Bytes
c8285c8d   Hu Chunming   GB28181 UDP 有重大进展...
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
  //

  // Created bxc on 2022/11/25.

  //

  

  #ifndef BXC_SIPSERVER_LOG_H

  #define BXC_SIPSERVER_LOG_H

  #include <time.h>

  #include <string>

  

  static std::string getTime() {

      const char* time_fmt = "%Y-%m-%d %H:%M:%S";

      time_t t = time(nullptr);

      char time_str[64];

      strftime(time_str, sizeof(time_str), time_fmt, localtime(&t));

  

      return time_str;

  }

  //  __FILE__ 获取源文件的相对路径和名字

  //  __LINE__ 获取该行代码在文件中的行号

  //  __func__  __FUNCTION__ 获取函数名

  

  #define LOGI(format, ...)  fprintf(stderr,"[INFO]%s [%s:%d %s()] " format "\n", getTime().data(),__FILE__,__LINE__,__func__ ,##__VA_ARGS__)

  #define LOGE(format, ...)  fprintf(stderr,"[ERROR]%s [%s:%d %s()] " format "\n",getTime().data(),__FILE__,__LINE__,__func__ ,##__VA_ARGS__)

  

  #endif //BXC_SIPSERVER_LOG_H