diff --git a/src/#mbtools#cl_logger.clas.abap b/src/#mbtools#cl_logger.clas.abap index 3358adc..5532582 100644 --- a/src/#mbtools#cl_logger.clas.abap +++ b/src/#mbtools#cl_logger.clas.abap @@ -632,7 +632,6 @@ CLASS /mbtools/cl_logger IMPLEMENTATION. "these objects could be moved into their own method "see adt://***/sap/bc/adt/oo/classes/zcl_logger/source/main#start=391,10;end=415,61 symsg TYPE symsg, - syst_buffer TYPE syst, loggable TYPE REF TO /mbtools/if_loggable_object, loggable_object_messages TYPE /mbtools/if_loggable_object=>tty_messages. @@ -643,7 +642,6 @@ CLASS /mbtools/cl_logger IMPLEMENTATION. FIELD-SYMBOLS LIKE LINE OF exception_data_table. " Remember system message since it might get changed inadvertently - syst_buffer = syst. IF context IS NOT INITIAL. ASSIGN context TO . formatted_context-value = . @@ -676,9 +674,7 @@ CLASS /mbtools/cl_logger IMPLEMENTATION. msg_type = cl_abap_typedescr=>describe_by_data( obj_to_log ). struct_kind = get_struct_kind( msg_type ). - IF obj_to_log IS INITIAL. - detailed_msg = add_syst_msg( syst_buffer ). - ELSEIF struct_kind = c_struct_kind-syst. + IF struct_kind = c_struct_kind-syst. detailed_msg = add_syst_msg( obj_to_log ). ELSEIF struct_kind = c_struct_kind-bapi. detailed_msg = add_bapi_msg( obj_to_log ). diff --git a/src/#mbtools#cl_logger.clas.testclasses.abap b/src/#mbtools#cl_logger.clas.testclasses.abap index ecf26b7..e608adf 100644 --- a/src/#mbtools#cl_logger.clas.testclasses.abap +++ b/src/#mbtools#cl_logger.clas.testclasses.abap @@ -98,7 +98,8 @@ can_create_anon_log FOR TESTING, can_log_bapi_meth_message FOR TESTING RAISING cx_static_check, can_log_bapi_status_result FOR TESTING RAISING cx_static_check, can_log_detlevel FOR TESTING RAISING cx_static_check, - can_log_exception_with_context FOR TESTING RAISING cx_static_check. + can_log_exception_with_context FOR TESTING RAISING cx_static_check, + nothing_logged_for_empty_obj FOR TESTING RAISING cx_static_check. ENDCLASS. @@ -2008,4 +2009,24 @@ CLASS lcl_test IMPLEMENTATION. ENDMETHOD. + METHOD nothing_logged_for_empty_obj. + DATA where_used_list TYPE bapiret2-message ##NEEDED. + DATA bapi_msgs TYPE TABLE OF bapiret2. + DATA bapi_msg TYPE bapiret2. + + MESSAGE i001(bl) INTO where_used_list + WITH 'This should' '*not*' 'be logged'. + CLEAR where_used_list. + + anon_log->add( bapi_msgs ). + cl_abap_unit_assert=>assert_equals( act = anon_log->length( ) + exp = 0 ). + anon_log->add( bapi_msg ). + cl_abap_unit_assert=>assert_equals( act = anon_log->length( ) + exp = 0 ). + anon_log->add( where_used_list ). + cl_abap_unit_assert=>assert_equals( act = anon_log->length( ) + exp = 0 ). + ENDMETHOD. + ENDCLASS. diff --git a/src/#mbtools#if_logger.intf.abap b/src/#mbtools#if_logger.intf.abap index 1849c6d..5ce7acb 100644 --- a/src/#mbtools#if_logger.intf.abap +++ b/src/#mbtools#if_logger.intf.abap @@ -7,7 +7,7 @@ INTERFACE /mbtools/if_logger METHODS add IMPORTING - obj_to_log TYPE any OPTIONAL + obj_to_log TYPE any DEFAULT sy context TYPE any OPTIONAL callback_form TYPE csequence OPTIONAL callback_prog TYPE csequence OPTIONAL @@ -22,7 +22,7 @@ INTERFACE /mbtools/if_logger METHODS a IMPORTING - obj_to_log TYPE any OPTIONAL + obj_to_log TYPE any DEFAULT sy context TYPE any OPTIONAL callback_form TYPE csequence OPTIONAL callback_prog TYPE csequence OPTIONAL @@ -36,7 +36,7 @@ INTERFACE /mbtools/if_logger METHODS e IMPORTING - obj_to_log TYPE any OPTIONAL + obj_to_log TYPE any DEFAULT sy context TYPE any OPTIONAL callback_form TYPE csequence OPTIONAL callback_prog TYPE csequence OPTIONAL @@ -50,7 +50,7 @@ INTERFACE /mbtools/if_logger METHODS w IMPORTING - obj_to_log TYPE any OPTIONAL + obj_to_log TYPE any DEFAULT sy context TYPE any OPTIONAL callback_form TYPE csequence OPTIONAL callback_prog TYPE csequence OPTIONAL @@ -64,7 +64,7 @@ INTERFACE /mbtools/if_logger METHODS i IMPORTING - obj_to_log TYPE any OPTIONAL + obj_to_log TYPE any DEFAULT sy context TYPE any OPTIONAL callback_form TYPE csequence OPTIONAL callback_prog TYPE csequence OPTIONAL @@ -78,7 +78,7 @@ INTERFACE /mbtools/if_logger METHODS s IMPORTING - obj_to_log TYPE any OPTIONAL + obj_to_log TYPE any DEFAULT sy context TYPE any OPTIONAL callback_form TYPE csequence OPTIONAL callback_prog TYPE csequence OPTIONAL