MCPcopy Create free account
hub / github.com/Haivision/srt / TestLogHandler

Function TestLogHandler

testing/srt-test-live.cpp:995–1022  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

993
994
995void TestLogHandler(void* opaque, int level, const char* file, int line, const char* area, const char* message)
996{
997 char prefix[100] = "";
998 if ( opaque ) {
999#ifdef _MSC_VER
1000 strncpy_s(prefix, sizeof(prefix), (char*)opaque, _TRUNCATE);
1001#else
1002 strncpy(prefix, (char*)opaque, sizeof(prefix) - 1);
1003 prefix[sizeof(prefix) - 1] = '\0';
1004#endif
1005 }
1006 time_t now;
1007 time(&now);
1008 char buf[1024];
1009 struct tm local = SysLocalTime(now);
1010 size_t pos = strftime(buf, 1024, "[%c ", &local);
1011
1012#ifdef _MSC_VER
1013 // That's something weird that happens on Microsoft Visual Studio 2013
1014 // Trying to keep portability, while every version of MSVS is a different platform.
1015 // On MSVS 2015 there's already a standard-compliant snprintf, whereas _snprintf
1016 // is available on backward compatibility and it doesn't work exactly the same way.
1017#define snprintf _snprintf
1018#endif
1019 snprintf(buf+pos, 1024-pos, "%s:%d(%s)]{%d} %s", file, line, area, level, message);
1020
1021 cerr << buf << endl;
1022}

Callers

nothing calls this directly

Calls 1

SysLocalTimeFunction · 0.85

Tested by

no test coverage detected