How to get only system.debug file when executing code?

I wrote a simple program and want to see the result when I run the code. When I run it in the Force.com IDE using the "Annoymously execute apex code" command, I get a lot of unwanted results when I only need system.debug instructions. I could use notepad or excel, but it seems that there should be a direct path (either native or a tool). Any tips?

Thanks,

el noobre

the code

public with sharing class Aa_playground { public static void listExp(){ List<Integer> x = new List<Integer>(); x.add(1212); for (Integer i = 0; i < x.size(); i++){ System.debug(x[i]); } } } 

Exit

 Anonymous execution was successful. 24.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO Execute Anonymous: Aa_playground.listExp(); 13:40:52.037 (37218000)|EXECUTION_STARTED 13:40:52.037 (37228000)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex 13:40:52.037 (37634000)|METHOD_ENTRY|[1]|01pQ000000062u5|Aa_playground.Aa_playground() 13:40:52.037 (37726000)|METHOD_EXIT|[1]|Aa_playground 13:40:52.037 (37740000)|METHOD_ENTRY|[1]|01pQ000000062u5|Aa_playground.listExp() 13:40:52.037 (37920000)|USER_DEBUG|[9]|DEBUG|1212 13:40:52.037 (37947000)|METHOD_EXIT|[1]|01pQ000000062u5|Aa_playground.listExp() 13:40:52.594 (37979000)|CUMULATIVE_LIMIT_USAGE 13:40:52.594|LIMIT_USAGE_FOR_NS|(default)| Number of SOQL queries: 0 out of 100 Number of query rows: 0 out of 50000 Number of SOSL queries: 0 out of 20 Number of DML statements: 0 out of 150 Number of DML rows: 0 out of 10000 Number of script statements: 5 out of 200000 Maximum heap size: 0 out of 6000000 Number of callouts: 0 out of 10 Number of Email Invocations: 0 out of 10 Number of fields describes: 0 out of 100 Number of record type describes: 0 out of 100 Number of child relationships describes: 0 out of 100 Number of picklist describes: 0 out of 100 Number of future calls: 0 out of 10 13:40:52.594|CUMULATIVE_LIMIT_USAGE_END 13:40:52.038 (38005000)|CODE_UNIT_FINISHED|execute_anonymous_apex 13:40:52.038 (38011000)|EXECUTION_FINISHED 
+6
source share
3 answers

I decided that I would summarize some of the information that I found in return.

  • Download Notepad ++ v6.1 +
  • In Notepad ++, open (or paste) your debug log file.
  • From the menu, select Macros> Start Recording.
  • Press CTRL-H (or shortcut for search and replace).
  • Copy this regular expression ^(?!.+USER_DEBUG.+$).*$ And paste it into the "Find that:" text box.
  • Ensure that the search mode is set to Regular Expression and that the Replace With: text box is blank.
  • Click Replace All and Good when the results dialog box appears.
  • Copy this regular expression (?m)^([ \t\s]*|;.*)(\r?\n|$) and paste it into the "Find that:" text box.
  • Ensure that the search mode is set to Regular Expression and that the Replace With: text box is blank.
  • Click Replace All and Good. Then close the Find and Replace dialog box.
  • From the menu, choose Macro> Stop Recording. Then choose Macro> Save Current Recorded Macro.
  • Enter a name for the new macro, and possibly set keyboard shortcuts. Then click OK.

To run a new macro, select Macro from the menu, and then click the name of your macro.

Credit for regular expressions refers to nivyaj (see comments on the question). Daniel Ballinger blog post was also helpful.

+7
source

This is probably bad practice, but what I have done in the past sets the APEX_CODE log level for INFO and also sets the debug message log level to information

 System.debug(Logginglevel.INFO, 'Debug Message with INFO level'); 
+5
source

You can delete LIMIT_USAGE_FOR_NS messages by setting the Apex Profiling level to None . But you cannot get rid of METHOD_ENTRY AND METHOD_EXIT and still receive USER_DEBUG messages, since these messages are higher than System.debug() messages in the filter. Unfortunately.

+1
source

Source: https://habr.com/ru/post/914060/


All Articles