295 #include <ti/utils/runtime/ILogger.h> 297 #if defined (__cplusplus) 310 #if ti_utils_runtime_Log_USE_LTO || ti_utils_runtime_Log_USE_PPO 312 #undef Log_MASK_INFO1 313 #undef Log_MASK_INFO2 314 #undef Log_MASK_INFO3 315 #undef Log_MASK_INFO4 316 #undef Log_MASK_INFO5 317 #undef Log_MASK_INFO6 319 #undef Log_MASK_ERROR 324 #undef _Log_DECL_Write 325 #undef _Log_DECL_Write_A 326 #undef _Log_DECL_Write_B 327 #undef _Log_DECL_Handle 328 #undef _Log_DECL_Handle_A 329 #undef _Log_DECL_Handle_B 330 #undef _Log_DECL_Level 331 #undef _Log_DECL_Level_A 332 #undef _Log_DECL_Level_B 334 #undef _Log_DECL_buf_A 335 #undef _Log_DECL_buf_B 336 #undef _Log_DECL_Printf 337 #undef _Log_DECL_Printf_A 338 #undef _Log_DECL_Printf_B 350 #undef _Log_NUMARGS_A 351 #undef _Log_NUMARGS_B 352 #undef _Log_CONCAT2_A 354 #undef _Log__TOKEN2STRING_A 355 #undef _Log_TOKEN2STRING 356 #undef _Log_APPEND_META_TO_FORMAT 357 #undef _Log_FIRST_ARG 358 #undef _Log_PLACE_FORMAT_IN_SECTOR 359 #undef _Log_GUARD_MACRO 363 #undef ti_utils_runtime_Log_USE_LTO 364 #undef ti_utils_runtime_Log_USE_PPO 365 #undef Log_DECLARE_MODULE 366 #undef _Log_DECL_Module_Id_Name 367 #undef Log_EVENT_CONSTRUCT 379 #ifdef ti_utils_runtime_Log_ENABLE_LTO 380 #undef ti_utils_runtime_Log_ENABLE_LTO 381 #define ti_utils_runtime_Log_USE_LTO 1 383 #define ti_utils_runtime_Log_USE_LTO 0 393 #ifdef ti_utils_runtime_Log_ENABLE_PPO 394 #undef ti_utils_runtime_Log_ENABLE_PPO 395 #define ti_utils_runtime_Log_USE_PPO 1 397 #define ti_utils_runtime_Log_USE_PPO 0 401 #if ti_utils_runtime_Log_USE_LTO && ti_utils_runtime_Log_USE_PPO 402 #error Cannot define both LTO and PPO at the same time. 405 #if ti_utils_runtime_Log_USE_LTO || ti_utils_runtime_Log_USE_PPO 414 #ifdef ti_utils_runtime_Log_ENABLE_ALL 415 #undef ti_utils_runtime_Log_ENABLE_ALL 417 #define Log_MASK_INFO1 Log_INFO1 418 #define Log_MASK_INFO2 Log_INFO2 419 #define Log_MASK_INFO3 Log_INFO3 420 #define Log_MASK_INFO4 Log_INFO4 421 #define Log_MASK_INFO5 Log_INFO5 422 #define Log_MASK_INFO6 Log_INFO6 423 #define Log_MASK_WARN Log_WARN 424 #define Log_MASK_ERROR Log_ERROR 428 #ifdef ti_utils_runtime_Log_ENABLE_INFO1 429 #undef ti_utils_runtime_Log_ENABLE_INFO1 430 #define Log_MASK_INFO1 Log_INFO1 432 #define Log_MASK_INFO1 0 435 #ifdef ti_utils_runtime_Log_ENABLE_INFO2 436 #undef ti_utils_runtime_Log_ENABLE_INFO2 437 #define Log_MASK_INFO2 Log_INFO2 439 #define Log_MASK_INFO2 0 442 #ifdef ti_utils_runtime_Log_ENABLE_INFO3 443 #undef ti_utils_runtime_Log_ENABLE_INFO3 444 #define Log_MASK_INFO3 Log_INFO3 446 #define Log_MASK_INFO3 0 449 #ifdef ti_utils_runtime_Log_ENABLE_INFO4 450 #undef ti_utils_runtime_Log_ENABLE_INFO4 451 #define Log_MASK_INFO4 Log_INFO4 453 #define Log_MASK_INFO4 0 456 #ifdef ti_utils_runtime_Log_ENABLE_INFO5 457 #undef ti_utils_runtime_Log_ENABLE_INFO5 458 #define Log_MASK_INFO5 Log_INFO5 460 #define Log_MASK_INFO5 0 463 #ifdef ti_utils_runtime_Log_ENABLE_INFO6 464 #undef ti_utils_runtime_Log_ENABLE_INFO6 465 #define Log_MASK_INFO6 Log_INFO6 467 #define Log_MASK_INFO6 0 470 #ifdef ti_utils_runtime_Log_ENABLE_WARN 471 #undef ti_utils_runtime_Log_ENABLE_WARN 472 #define Log_MASK_WARN Log_WARN 474 #define Log_MASK_WARN 0 477 #ifdef ti_utils_runtime_Log_ENABLE_ERROR 478 #undef ti_utils_runtime_Log_ENABLE_ERROR 479 #define Log_MASK_ERROR Log_ERROR 481 #define Log_MASK_ERROR 0 487 Log_MASK_INFO1 | Log_MASK_INFO2 | Log_MASK_INFO3 | \ 488 Log_MASK_INFO4 | Log_MASK_INFO5 | Log_MASK_INFO6 | \ 489 Log_MASK_WARN | Log_MASK_ERROR) 497 #define _Log_GUARD_MACRO(x) do{ x }while(0) 513 #define _Log_FIRST_ARG(N, ...) N 516 #define _Log_EVENT_ARGS(module, header, ...) \ 517 _Log_EVENT_ARGS_A(module, header, _Log_NUMARGS(__VA_ARGS__), __VA_ARGS__) 518 #define _Log_EVENT_ARGS_A(module, header, num, ...) \ 519 _Log_EVENT_ARGS_B(module, header, num, __VA_ARGS__) 520 #define _Log_EVENT_ARGS_B(module, header, num, ...) \ 521 _Log_EVENT_ARGS##num(module, uintptr_t, header, __VA_ARGS__) 524 #define _Log_EVENT_ARGS0(module, type, header, event) \ 526 (uintptr_t)module##_##event, \ 532 #define _Log_EVENT_ARGS1(module, type, header, event, a1) \ 534 (uintptr_t)module##_##event, \ 540 #define _Log_EVENT_ARGS2(module, type, header, event, a1, a2) \ 542 (uintptr_t)module##_##event, \ 548 #define _Log_EVENT_ARGS3(module, type, header, event, a1, a2, a3) \ 550 (uintptr_t)module##_##event, \ 556 #define _Log_EVENT_ARGS4(module, type, header, event, a1, a2, a3, a4) \ 558 (uintptr_t)module##_##event, \ 565 #define _Log_NUMARGS(...) _Log_NUMARGS_A(__VA_ARGS__, 4, 3, 2, 1, 0) 566 #define _Log_NUMARGS_A(...) _Log_NUMARGS_B(__VA_ARGS__) 567 #define _Log_NUMARGS_B(_first, _4, _3, _2, _1, N, ...) N 573 #define _Log_CONCAT2_A(x,y) x ## _ ## y 574 #define _Log_CONCAT2(x,y) _Log_CONCAT2_A(x,y) 577 #define _Log__TOKEN2STRING_A(x) #x 578 #define _Log_TOKEN2STRING(x) _Log__TOKEN2STRING_A(x) 581 #define _Log_APPEND_META_TO_FORMAT(opcode, \ 588 _Log_TOKEN2STRING(opcode) "\x1e" \ 589 _Log_TOKEN2STRING(file) "\x1e" \ 590 _Log_TOKEN2STRING(line) "\x1e" \ 591 _Log_TOKEN2STRING(level) "\x1e" \ 592 _Log_TOKEN2STRING(module) "\x1e" \ 593 _Log_TOKEN2STRING(format) "\x1e" \ 594 _Log_TOKEN2STRING(nargs) 599 #if defined(__IAR_SYSTEMS_ICC__) 600 #define _Log_PLACE_FORMAT_IN_SECTOR(name, opcode, level, module, format, nargs)\ 601 __root static const char name[] @ ".log_data" = \ 602 _Log_APPEND_META_TO_FORMAT(opcode, \ 609 #elif defined(__TI_COMPILER_VERSION__) || (defined(__clang__) && defined(__ti_version__)) || defined(__GNUC__) 610 #define _Log_PLACE_FORMAT_IN_SECTOR(name, opcode, level, module, format, nargs)\ 611 static const char name[] \ 612 __attribute__((used,section(".log_data"))) = \ 613 _Log_APPEND_META_TO_FORMAT(opcode, \ 621 #error Incompatible compiler: Logging is currently supported by the following \ 622 compilers: TI ARM Compiler, TI CLANG Compiler, GCC, IAR. Please migrate to a \ 623 a supported compiler. 643 #define Log_DECLARE_MODULE(module) \ 644 _Log_DECL_Write(module); \ 645 _Log_DECL_Printf(module); \ 646 _Log_DECL_buf(module); \ 647 _Log_DECL_Handle(module); \ 648 _Log_DECL_Level(module); 651 #define _Log_DECL_Write(module) _Log_DECL_Write_A(module) 652 #define _Log_DECL_Write_A(module) _Log_DECL_Write_B(module) 653 #define _Log_DECL_Write_B(module) \ 654 extern void module##_LogSite_event(ILogger_Handle logger, \ 662 #define _Log_DECL_Printf(module) _Log_DECL_Printf_A(module) 663 #define _Log_DECL_Printf_A(module) _Log_DECL_Printf_B(module) 664 #define _Log_DECL_Printf_B(module) \ 665 extern void module##_LogSite_printf(ILogger_Handle handle, \ 670 #define _Log_DECL_buf(module) _Log_DECL_buf_A(module) 671 #define _Log_DECL_buf_A(module) _Log_DECL_buf_B(module) 672 #define _Log_DECL_buf_B(module) \ 673 extern void module##_LogSite_buf(ILogger_Handle handle, \ 675 const char* format, \ 679 #define _Log_DECL_Handle(module) _Log_DECL_Handle_A(module) 680 #define _Log_DECL_Handle_A(module) _Log_DECL_Handle_B(module) 681 #define _Log_DECL_Handle_B(module) \ 682 extern const ILogger_Handle module##_LogSite_handle 684 #define _Log_DECL_Level(module) _Log_DECL_Level_A(module) 685 #define _Log_DECL_Level_A(module) _Log_DECL_Level_B(module) 686 #define _Log_DECL_Level_B(module) \ 687 extern const uint32_t module##_LogSite_level 689 #if ti_utils_runtime_Log_USE_LTO 691 #define _Log_event_B(module, level, ...) \ 692 if ((level) & module##_LogSite_level) { \ 693 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 697 _Log_FIRST_ARG(__VA_ARGS__), \ 698 _Log_NUMARGS(__VA_ARGS__)) \ 699 module##_LogSite_event(module##_LogSite_handle, \ 700 _Log_EVENT_ARGS(module, \ 701 &_Log_CONCAT2(LogSymbol, \ 708 #if ti_utils_runtime_Log_USE_PPO 710 #define _Log_event_B(module, level, ...) \ 711 if ((level) & (Log_MASK)) { \ 712 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 716 _Log_FIRST_ARG(__VA_ARGS__), \ 717 _Log_NUMARGS(__VA_ARGS__)) \ 718 module##_LogSite_event(module##_LogSite_handle, \ 719 _Log_EVENT_ARGS(module, \ 720 &_Log_CONCAT2(LogSymbol, \ 727 #if ti_utils_runtime_Log_USE_LTO 729 #define _Log_buf_B(module , level, format, data, size) \ 730 if ((level) & module##_LogSite_level) { \ 731 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 737 module##_LogSite_buf(module##_LogSite_handle, \ 738 (uint32_t)&_Log_CONCAT2(LogSymbol, __LINE__), \ 746 #if ti_utils_runtime_Log_USE_PPO 748 #define _Log_buf_B(module , level, format, data, size) \ 749 if ((level) & (Log_MASK)) { \ 750 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 756 module##_LogSite_buf(module##_LogSite_handle, \ 757 (uint32_t)&_Log_CONCAT2(LogSymbol, __LINE__), \ 765 #if ti_utils_runtime_Log_USE_LTO 767 #define _Log_printf_B(module, level, ...) \ 768 if ((level) & module##_LogSite_level) { \ 769 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 770 LOG_OPCODE_FORMATED_TEXT, \ 773 _Log_FIRST_ARG(__VA_ARGS__), \ 774 _Log_NUMARGS(__VA_ARGS__)) \ 775 module##_LogSite_printf(module##_LogSite_handle, \ 776 (uint32_t)&_Log_CONCAT2(LogSymbol, __LINE__), \ 777 _Log_NUMARGS(__VA_ARGS__), \ 783 #if ti_utils_runtime_Log_USE_PPO 785 #define _Log_printf_B(module, level, ...) \ 786 if ((level) & (Log_MASK)) { \ 787 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 788 LOG_OPCODE_FORMATED_TEXT, \ 791 _Log_FIRST_ARG(__VA_ARGS__), \ 792 _Log_NUMARGS(__VA_ARGS__)) \ 793 module##_LogSite_printf(module##_LogSite_handle, \ 794 (uint32_t)&_Log_CONCAT2(LogSymbol, __LINE__), \ 795 _Log_NUMARGS(__VA_ARGS__), \ 824 #define Log_event(module, level, ...) \ 825 _Log_GUARD_MACRO(_Log_event_B(module , level, __VA_ARGS__)) 843 #define Log_EVENT_CONSTRUCT(module, name, fmt) \ 844 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, name), \ 845 LOG_EVENT_CONSTRUCT, \ 850 const char *_Log_CONCAT2(module, name) = _Log_CONCAT2(LogSymbol, \ 868 #define Log_buf(module, level, format, data, size) \ 869 _Log_GUARD_MACRO(_Log_buf_B(module , level, format, data, size)) 889 #define Log_printf(module, level, ...) \ 890 _Log_GUARD_MACRO(_Log_printf_B(module, level, __VA_ARGS__)) 899 #define _Log_DECL_Config() 900 #define _Log_DECL_Module_Id_Name(module) 901 #define Log_EVENT_CONSTRUCT(name, type, fmt) 902 #define Log_event(level, ...) 941 extern const uint32_t ti_utils_runtime_LogMain_LogSite_level;
942 extern const ILogger_Handle ti_utils_runtime_LogMain_LogSite_handle;
943 extern void ti_utils_runtime_LogMain_LogSite_event(ILogger_Handle,
950 extern void ti_utils_runtime_LogMain_LogSite_printf(ILogger_Handle handle,
954 extern void ti_utils_runtime_LogMain_LogSite_buf(ILogger_Handle handle,
964 #if defined (__cplusplus)
Log_Level
Definition: Log.h:925