MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / hb_valog

Function hb_valog

libhb/common.c:4448–4512  ·  view source on GitHub ↗

Necessary for hb_deep_log * hb_valog ********************************************************************** * If verbose mode is one, print message with timestamp. Messages * longer than 180 characters are stripped ;p *********************************************************************/

Source from the content-addressed store, hash-verified

4446 * longer than 180 characters are stripped ;p
4447 *********************************************************************/
4448void hb_valog( hb_debug_level_t level, const char * prefix, const char * log, va_list args)
4449{
4450 char * string;
4451 time_t _now;
4452 struct tm * now;
4453 char preamble[362];
4454
4455 if( global_verbosity_level < level )
4456 {
4457 /* Hiding message */
4458 return;
4459 }
4460
4461 /* Get the time */
4462 _now = time( NULL );
4463 now = localtime( &_now );
4464 if ( prefix && *prefix )
4465 {
4466 // limit the prefix length
4467 snprintf( preamble, 361, "[%02d:%02d:%02d] %s %s\n",
4468 now->tm_hour, now->tm_min, now->tm_sec, prefix, log );
4469 }
4470 else
4471 {
4472 snprintf( preamble, 361, "[%02d:%02d:%02d] %s\n",
4473 now->tm_hour, now->tm_min, now->tm_sec, log );
4474 }
4475
4476 string = hb_strdup_vaprintf(preamble, args);
4477
4478#ifdef SYS_MINGW
4479 wchar_t *wstring; /* 360 chars + \n + \0 */
4480 int len;
4481
4482 len = strlen(string) + 1;
4483 wstring = malloc(2 * len);
4484
4485 // Convert internal utf8 to "console output code page".
4486 //
4487 // This is just bizarre windows behavior. You would expect that
4488 // printf would automatically convert a wide character string to
4489 // the current "console output code page" when using the "%ls" format
4490 // specifier. But it doesn't... so we must do it.
4491 if (!MultiByteToWideChar(CP_UTF8, 0, string, -1, wstring, len))
4492 {
4493 free(string);
4494 free(wstring);
4495 return;
4496 }
4497 free(string);
4498 string = malloc(2 * len);
4499 if (!WideCharToMultiByte(GetConsoleOutputCP(), 0, wstring, -1, string, len,
4500 NULL, NULL))
4501 {
4502 free(string);
4503 free(wstring);
4504 return;
4505 }

Callers 3

ssa_logFunction · 0.85
hb_logFunction · 0.85
hb_deep_logFunction · 0.85

Calls 1

hb_strdup_vaprintfFunction · 0.85

Tested by

no test coverage detected