300 #include <ti/utils/runtime/ILogger.h> 302 #if defined(__cplusplus) 314 #if ti_utils_runtime_Log_USE_LTO || ti_utils_runtime_Log_USE_PPO 316 #undef Log_MASK_INFO1 317 #undef Log_MASK_INFO2 318 #undef Log_MASK_INFO3 319 #undef Log_MASK_INFO4 320 #undef Log_MASK_INFO5 321 #undef Log_MASK_INFO6 323 #undef Log_MASK_ERROR 328 #undef _Log_DECL_Write 329 #undef _Log_DECL_Write_A 330 #undef _Log_DECL_Write_B 331 #undef _Log_DECL_Handle 332 #undef _Log_DECL_Handle_A 333 #undef _Log_DECL_Handle_B 334 #undef _Log_DECL_Level 335 #undef _Log_DECL_Level_A 336 #undef _Log_DECL_Level_B 338 #undef _Log_DECL_buf_A 339 #undef _Log_DECL_buf_B 340 #undef _Log_DECL_Printf 341 #undef _Log_DECL_Printf_A 342 #undef _Log_DECL_Printf_B 353 #undef _Log_NUMARGS_A 354 #undef _Log_NUMARGS_B 355 #undef _Log_CONCAT2_A 357 #undef _Log__TOKEN2STRING_A 358 #undef _Log_TOKEN2STRING 359 #undef _Log_APPEND_META_TO_FORMAT 360 #undef _Log_FIRST_ARG 361 #undef _Log_PLACE_FORMAT_IN_SECTOR 362 #undef _Log_GUARD_MACRO 366 #undef ti_utils_runtime_Log_USE_LTO 367 #undef ti_utils_runtime_Log_USE_PPO 368 #undef Log_DECLARE_MODULE 369 #undef _Log_DECL_Module_Id_Name 370 #undef Log_EVENT_CONSTRUCT 382 #ifdef ti_utils_runtime_Log_ENABLE_LTO 383 #undef ti_utils_runtime_Log_ENABLE_LTO 384 #define ti_utils_runtime_Log_USE_LTO 1 386 #define ti_utils_runtime_Log_USE_LTO 0 396 #ifdef ti_utils_runtime_Log_ENABLE_PPO 397 #undef ti_utils_runtime_Log_ENABLE_PPO 398 #define ti_utils_runtime_Log_USE_PPO 1 400 #define ti_utils_runtime_Log_USE_PPO 0 404 #if ti_utils_runtime_Log_USE_LTO && ti_utils_runtime_Log_USE_PPO 405 #error Cannot define both LTO and PPO at the same time. 408 #if ti_utils_runtime_Log_USE_LTO || ti_utils_runtime_Log_USE_PPO 417 #ifdef ti_utils_runtime_Log_ENABLE_ALL 418 #undef ti_utils_runtime_Log_ENABLE_ALL 420 #define Log_MASK_INFO1 Log_INFO1 421 #define Log_MASK_INFO2 Log_INFO2 422 #define Log_MASK_INFO3 Log_INFO3 423 #define Log_MASK_INFO4 Log_INFO4 424 #define Log_MASK_INFO5 Log_INFO5 425 #define Log_MASK_INFO6 Log_INFO6 426 #define Log_MASK_WARN Log_WARN 427 #define Log_MASK_ERROR Log_ERROR 431 #ifdef ti_utils_runtime_Log_ENABLE_INFO1 432 #undef ti_utils_runtime_Log_ENABLE_INFO1 433 #define Log_MASK_INFO1 Log_INFO1 435 #define Log_MASK_INFO1 0 438 #ifdef ti_utils_runtime_Log_ENABLE_INFO2 439 #undef ti_utils_runtime_Log_ENABLE_INFO2 440 #define Log_MASK_INFO2 Log_INFO2 442 #define Log_MASK_INFO2 0 445 #ifdef ti_utils_runtime_Log_ENABLE_INFO3 446 #undef ti_utils_runtime_Log_ENABLE_INFO3 447 #define Log_MASK_INFO3 Log_INFO3 449 #define Log_MASK_INFO3 0 452 #ifdef ti_utils_runtime_Log_ENABLE_INFO4 453 #undef ti_utils_runtime_Log_ENABLE_INFO4 454 #define Log_MASK_INFO4 Log_INFO4 456 #define Log_MASK_INFO4 0 459 #ifdef ti_utils_runtime_Log_ENABLE_INFO5 460 #undef ti_utils_runtime_Log_ENABLE_INFO5 461 #define Log_MASK_INFO5 Log_INFO5 463 #define Log_MASK_INFO5 0 466 #ifdef ti_utils_runtime_Log_ENABLE_INFO6 467 #undef ti_utils_runtime_Log_ENABLE_INFO6 468 #define Log_MASK_INFO6 Log_INFO6 470 #define Log_MASK_INFO6 0 473 #ifdef ti_utils_runtime_Log_ENABLE_WARN 474 #undef ti_utils_runtime_Log_ENABLE_WARN 475 #define Log_MASK_WARN Log_WARN 477 #define Log_MASK_WARN 0 480 #ifdef ti_utils_runtime_Log_ENABLE_ERROR 481 #undef ti_utils_runtime_Log_ENABLE_ERROR 482 #define Log_MASK_ERROR Log_ERROR 484 #define Log_MASK_ERROR 0 490 (Log_MASK_INFO1 | Log_MASK_INFO2 | Log_MASK_INFO3 | Log_MASK_INFO4 | Log_MASK_INFO5 | Log_MASK_INFO6 | \ 491 Log_MASK_WARN | Log_MASK_ERROR) 498 #define _Log_GUARD_MACRO(x) \ 518 #define _Log_FIRST_ARG(N, ...) N 521 #define _Log_EVENT_ARGS(module, header, ...) \ 522 _Log_EVENT_ARGS_A(module, header, _Log_NUMARGS(__VA_ARGS__), __VA_ARGS__) 523 #define _Log_EVENT_ARGS_A(module, header, num, ...) _Log_EVENT_ARGS_B(module, header, num, __VA_ARGS__) 524 #define _Log_EVENT_ARGS_B(module, header, num, ...) _Log_EVENT_ARGS##num(module, uintptr_t, header, __VA_ARGS__) 527 #define _Log_EVENT_ARGS0(module, type, header, event) \ 528 (uint32_t) header, (uintptr_t)module##_##event, (type)0, (type)0, (type)0, (type)0 530 #define _Log_EVENT_ARGS1(module, type, header, event, a1) \ 531 (uint32_t) header, (uintptr_t)module##_##event, (type)a1, (type)0, (type)0, (type)0 533 #define _Log_EVENT_ARGS2(module, type, header, event, a1, a2) \ 534 (uint32_t) header, (uintptr_t)module##_##event, (type)a1, (type)a2, (type)0, (type)0 536 #define _Log_EVENT_ARGS3(module, type, header, event, a1, a2, a3) \ 537 ((uint32_t)header, (uintptr_t)module##_##event, (type)a1, (type)a2, (type)a3, (type)0) 539 #define _Log_EVENT_ARGS4(module, type, header, event, a1, a2, a3, a4) \ 540 (uint32_t) header, (uintptr_t)module##_##event, (type)a1, (type)a2, (type)a3, (type)a4 543 #define _Log_NUMARGS(...) _Log_NUMARGS_A(__VA_ARGS__, 4, 3, 2, 1, 0) 544 #define _Log_NUMARGS_A(...) _Log_NUMARGS_B(__VA_ARGS__) 545 #define _Log_NUMARGS_B(_first, _4, _3, _2, _1, N, ...) N 551 #define _Log_CONCAT2_A(x, y) x##_##y 552 #define _Log_CONCAT2(x, y) _Log_CONCAT2_A(x, y) 555 #define _Log__TOKEN2STRING_A(x) #x 556 #define _Log_TOKEN2STRING(x) _Log__TOKEN2STRING_A(x) 559 #define _Log_APPEND_META_TO_FORMAT(opcode, file, line, level, module, format, nargs) \ 560 _Log_TOKEN2STRING(opcode) "\x1e" _Log_TOKEN2STRING(file) "\x1e" _Log_TOKEN2STRING(line) "\x1e" _Log_TOKEN2STRING( \ 561 level) "\x1e" _Log_TOKEN2STRING(module) "\x1e" _Log_TOKEN2STRING(format) "\x1e" _Log_TOKEN2STRING(nargs) 566 #if defined(__IAR_SYSTEMS_ICC__) 567 #define _Log_PLACE_FORMAT_IN_SECTOR(name, opcode, level, module, format, nargs) \ 568 #pragma location = ".log_data" __root static const char \ 569 name[] = _Log_APPEND_META_TO_FORMAT(opcode, __FILE__, __LINE__, level, module, format, nargs); 570 #elif defined(__TI_COMPILER_VERSION__) || (defined(__clang__) && defined(__ti_version__)) || defined(__GNUC__) 571 #define _Log_PLACE_FORMAT_IN_SECTOR(name, opcode, level, module, format, nargs) \ 572 static const char name[] \ 573 __attribute__((used, section(".log_data"))) = _Log_APPEND_META_TO_FORMAT(opcode, \ 581 #error Incompatible compiler: Logging is currently supported by the following \ 582 compilers: TI ARM Compiler, TI CLANG Compiler, GCC, IAR. Please migrate to a \ 583 a supported compiler. 603 #define Log_DECLARE_MODULE(module) \ 604 _Log_DECL_Write(module); \ 605 _Log_DECL_Printf(module); \ 606 _Log_DECL_buf(module); \ 607 _Log_DECL_Handle(module); \ 608 _Log_DECL_Level(module); 611 #define _Log_DECL_Write(module) _Log_DECL_Write_A(module) 612 #define _Log_DECL_Write_A(module) _Log_DECL_Write_B(module) 613 #define _Log_DECL_Write_B(module) \ 614 extern void module##_LogSite_event(ILogger_Handle logger, \ 622 #define _Log_DECL_Printf(module) _Log_DECL_Printf_A(module) 623 #define _Log_DECL_Printf_A(module) _Log_DECL_Printf_B(module) 624 #define _Log_DECL_Printf_B(module) \ 625 extern void module##_LogSite_printf(ILogger_Handle handle, uint32_t header, uint32_t numArgs, ...) 627 #define _Log_DECL_buf(module) _Log_DECL_buf_A(module) 628 #define _Log_DECL_buf_A(module) _Log_DECL_buf_B(module) 629 #define _Log_DECL_buf_B(module) \ 630 extern void module##_LogSite_buf(ILogger_Handle handle, \ 632 const char *format, \ 636 #define _Log_DECL_Handle(module) _Log_DECL_Handle_A(module) 637 #define _Log_DECL_Handle_A(module) _Log_DECL_Handle_B(module) 638 #define _Log_DECL_Handle_B(module) extern const ILogger_Handle module##_LogSite_handle 640 #define _Log_DECL_Level(module) _Log_DECL_Level_A(module) 641 #define _Log_DECL_Level_A(module) _Log_DECL_Level_B(module) 642 #define _Log_DECL_Level_B(module) extern const uint32_t module##_LogSite_level 644 #if ti_utils_runtime_Log_USE_LTO 646 #define _Log_event_B(module, level, ...) \ 647 if ((level)&module##_LogSite_level) \ 649 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 653 _Log_FIRST_ARG(__VA_ARGS__), \ 654 _Log_NUMARGS(__VA_ARGS__)) \ 655 module##_LogSite_event(module##_LogSite_handle, \ 656 _Log_EVENT_ARGS(module, &_Log_CONCAT2(LogSymbol, __LINE__), __VA_ARGS__)); \ 661 #if ti_utils_runtime_Log_USE_PPO 663 #define _Log_event_B(module, level, ...) \ 664 if ((level) & (Log_MASK)) \ 666 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 670 _Log_FIRST_ARG(__VA_ARGS__), \ 671 _Log_NUMARGS(__VA_ARGS__)) \ 672 module##_LogSite_event(module##_LogSite_handle, \ 673 _Log_EVENT_ARGS(module, &_Log_CONCAT2(LogSymbol, __LINE__), __VA_ARGS__)); \ 678 #if ti_utils_runtime_Log_USE_LTO 680 #define _Log_buf_B(module, level, format, data, size) \ 681 if ((level)&module##_LogSite_level) \ 683 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 688 0) module##_LogSite_buf(module##_LogSite_handle, \ 689 (uint32_t)&_Log_CONCAT2(LogSymbol, __LINE__), \ 697 #if ti_utils_runtime_Log_USE_PPO 699 #define _Log_buf_B(module, level, format, data, size) \ 700 if ((level) & (Log_MASK)) \ 702 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 707 0) module##_LogSite_buf(module##_LogSite_handle, \ 708 (uint32_t)&_Log_CONCAT2(LogSymbol, __LINE__), \ 716 #if ti_utils_runtime_Log_USE_LTO 718 #define _Log_printf_B(module, level, ...) \ 719 if ((level)&module##_LogSite_level) \ 721 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 722 LOG_OPCODE_FORMATED_TEXT, \ 725 _Log_FIRST_ARG(__VA_ARGS__), \ 726 _Log_NUMARGS(__VA_ARGS__)) \ 727 module##_LogSite_printf(module##_LogSite_handle, \ 728 (uint32_t)&_Log_CONCAT2(LogSymbol, __LINE__), \ 729 _Log_NUMARGS(__VA_ARGS__), \ 735 #if ti_utils_runtime_Log_USE_PPO 737 #define _Log_printf_B(module, level, ...) \ 738 if ((level) & (Log_MASK)) \ 740 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, __LINE__), \ 741 LOG_OPCODE_FORMATED_TEXT, \ 744 _Log_FIRST_ARG(__VA_ARGS__), \ 745 _Log_NUMARGS(__VA_ARGS__)) \ 746 module##_LogSite_printf(module##_LogSite_handle, \ 747 (uint32_t)&_Log_CONCAT2(LogSymbol, __LINE__), \ 748 _Log_NUMARGS(__VA_ARGS__), \ 777 #define Log_event(module, level, ...) _Log_GUARD_MACRO(_Log_event_B(module, level, __VA_ARGS__)) 794 #define Log_EVENT_CONSTRUCT(module, name, fmt) \ 795 _Log_PLACE_FORMAT_IN_SECTOR(_Log_CONCAT2(LogSymbol, name), LOG_EVENT_CONSTRUCT, name, module, fmt, 0) \ 796 const char *_Log_CONCAT2(module, name) = _Log_CONCAT2(LogSymbol, name); 812 #define Log_buf(module, level, format, data, size) _Log_GUARD_MACRO(_Log_buf_B(module, level, format, data, size)) 832 #define Log_printf(module, level, ...) _Log_GUARD_MACRO(_Log_printf_B(module, level, __VA_ARGS__)) 841 #define _Log_DECL_Config() 842 #define _Log_DECL_Module_Id_Name(module) 843 #define Log_EVENT_CONSTRUCT(name, type, fmt) 844 #define Log_event(level, ...) 884 extern const uint32_t ti_utils_runtime_LogMain_LogSite_level;
885 extern const ILogger_Handle ti_utils_runtime_LogMain_LogSite_handle;
886 extern void ti_utils_runtime_LogMain_LogSite_event(ILogger_Handle,
893 extern void ti_utils_runtime_LogMain_LogSite_printf(ILogger_Handle handle, uint32_t header, uint32_t numArgs, ...);
894 extern void ti_utils_runtime_LogMain_LogSite_buf(ILogger_Handle handle,
903 #if defined(__cplusplus)
Log_Level
Definition: Log.h:867