Java-1457 Reduce logging - Modules jgit, libraries-testing (#9884)
* Java-1457 Reduce logging - Modules jgit, libraries-testing * Java-1457 Reduce logging - Modules jgit, libraries-testing Co-authored-by: mikr <michael.krimgen@ximedes.com>
This commit is contained in:
		
							parent
							
								
									e4f034795d
								
							
						
					
					
						commit
						afd00056a2
					
				| @ -6,6 +6,8 @@ import com.baeldung.jgit.helper.Helper; | ||||
| import org.eclipse.jgit.api.Git; | ||||
| import org.eclipse.jgit.api.errors.GitAPIException; | ||||
| import org.eclipse.jgit.lib.Repository; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
| /** | ||||
|  * Simple snippet which shows how to add a file to the index | ||||
| @ -14,6 +16,8 @@ import org.eclipse.jgit.lib.Repository; | ||||
|  */ | ||||
| public class AddFile { | ||||
| 
 | ||||
|     private static final Logger logger = LoggerFactory.getLogger(AddFile.class); | ||||
| 
 | ||||
|     public static void main(String[] args) throws IOException, GitAPIException { | ||||
|         // prepare a new test-repository | ||||
|         try (Repository repository = Helper.createNewRepository()) { | ||||
| @ -29,7 +33,7 @@ public class AddFile { | ||||
|                         .addFilepattern("testfile") | ||||
|                         .call(); | ||||
| 
 | ||||
|                 System.out.println("Added file " + myfile + " to repository at " + repository.getDirectory()); | ||||
|                 logger.debug("Added file " + myfile + " to repository at " + repository.getDirectory()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -7,6 +7,8 @@ import com.baeldung.jgit.helper.Helper; | ||||
| import org.eclipse.jgit.api.Git; | ||||
| import org.eclipse.jgit.api.errors.GitAPIException; | ||||
| import org.eclipse.jgit.lib.Repository; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
| /** | ||||
|  * Simple snippet which shows how to commit all files | ||||
| @ -15,6 +17,8 @@ import org.eclipse.jgit.lib.Repository; | ||||
|  */ | ||||
| public class CommitAll { | ||||
| 
 | ||||
|     private static final Logger logger = LoggerFactory.getLogger(CommitAll.class); | ||||
| 
 | ||||
|     public static void main(String[] args) throws IOException, GitAPIException { | ||||
|         // prepare a new test-repository | ||||
|         try (Repository repository = Helper.createNewRepository()) { | ||||
| @ -44,7 +48,7 @@ public class CommitAll { | ||||
|                         .call(); | ||||
| 
 | ||||
| 
 | ||||
|                 System.out.println("Committed all changes to repository at " + repository.getDirectory()); | ||||
|                 logger.debug("Committed all changes to repository at " + repository.getDirectory()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -9,6 +9,8 @@ import org.eclipse.jgit.lib.Ref; | ||||
| import org.eclipse.jgit.lib.Repository; | ||||
| import org.eclipse.jgit.revwalk.RevCommit; | ||||
| import org.eclipse.jgit.revwalk.RevWalk; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
| /** | ||||
|  * Simple snippet which shows how to create a tag | ||||
| @ -17,6 +19,8 @@ import org.eclipse.jgit.revwalk.RevWalk; | ||||
|  */ | ||||
| public class CreateAndDeleteTag { | ||||
| 
 | ||||
|     private static final Logger logger = LoggerFactory.getLogger(CreateAndDeleteTag.class); | ||||
| 
 | ||||
|     public static void main(String[] args) throws IOException, GitAPIException { | ||||
|         // prepare test-repository | ||||
|         try (Repository repository = Helper.openJGitRepository()) { | ||||
| @ -26,7 +30,7 @@ public class CreateAndDeleteTag { | ||||
| 
 | ||||
|                 // set it on the current HEAD | ||||
|                 Ref tag = git.tag().setName("tag_for_testing").call(); | ||||
|                 System.out.println("Created/moved tag " + tag + " to repository at " + repository.getDirectory()); | ||||
|                 logger.debug("Created/moved tag " + tag + " to repository at " + repository.getDirectory()); | ||||
| 
 | ||||
|                 // remove the tag again | ||||
|                 git.tagDelete().setTags("tag_for_testing").call(); | ||||
| @ -36,14 +40,14 @@ public class CreateAndDeleteTag { | ||||
|                 try (RevWalk walk = new RevWalk(repository)) { | ||||
|                     RevCommit commit = walk.parseCommit(id); | ||||
|                     tag = git.tag().setObjectId(commit).setName("tag_for_testing").call(); | ||||
|                     System.out.println("Created/moved tag " + tag + " to repository at " + repository.getDirectory()); | ||||
|                     logger.debug("Created/moved tag " + tag + " to repository at " + repository.getDirectory()); | ||||
| 
 | ||||
|                     // remove the tag again | ||||
|                     git.tagDelete().setTags("tag_for_testing").call(); | ||||
| 
 | ||||
|                     // create an annotated tag | ||||
|                     tag = git.tag().setName("tag_for_testing").setAnnotated(true).call(); | ||||
|                     System.out.println("Created/moved tag " + tag + " to repository at " + repository.getDirectory()); | ||||
|                     logger.debug("Created/moved tag " + tag + " to repository at " + repository.getDirectory()); | ||||
| 
 | ||||
|                     // remove the tag again | ||||
|                     git.tagDelete().setTags("tag_for_testing").call(); | ||||
|  | ||||
| @ -7,6 +7,9 @@ import org.eclipse.jgit.api.errors.GitAPIException; | ||||
| import org.eclipse.jgit.lib.Repository; | ||||
| import org.eclipse.jgit.revwalk.RevCommit; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
| /** | ||||
|  * Simple snippet which shows how to get the commit-ids for a file to provide log information. | ||||
|  * | ||||
| @ -14,6 +17,8 @@ import org.eclipse.jgit.revwalk.RevCommit; | ||||
|  */ | ||||
| public class Log { | ||||
| 
 | ||||
|     private static final Logger logger = LoggerFactory.getLogger(Log.class); | ||||
| 
 | ||||
|     @SuppressWarnings("unused") | ||||
|     public static void main(String[] args) throws IOException, GitAPIException { | ||||
|         try (Repository repository = Helper.openJGitRepository()) { | ||||
| @ -22,30 +27,30 @@ public class Log { | ||||
|                         .call(); | ||||
|                 int count = 0; | ||||
|                 for (RevCommit rev : logs) { | ||||
|                     //System.out.println("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); | ||||
|                     logger.trace("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); | ||||
|                     count++; | ||||
|                 } | ||||
|                 System.out.println("Had " + count + " commits overall on current branch"); | ||||
|                 logger.debug("Had " + count + " commits overall on current branch"); | ||||
| 
 | ||||
|                 logs = git.log() | ||||
|                         .add(repository.resolve(git.getRepository().getFullBranch())) | ||||
|                         .call(); | ||||
|                 count = 0; | ||||
|                 for (RevCommit rev : logs) { | ||||
|                     System.out.println("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); | ||||
|                     logger.trace("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); | ||||
|                     count++; | ||||
|                 } | ||||
|                 System.out.println("Had " + count + " commits overall on "+git.getRepository().getFullBranch()); | ||||
|                 logger.debug("Had " + count + " commits overall on "+git.getRepository().getFullBranch()); | ||||
| 
 | ||||
|                 logs = git.log() | ||||
|                         .all() | ||||
|                         .call(); | ||||
|                 count = 0; | ||||
|                 for (RevCommit rev : logs) { | ||||
|                     //System.out.println("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); | ||||
|                     logger.trace("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); | ||||
|                     count++; | ||||
|                 } | ||||
|                 System.out.println("Had " + count + " commits overall in repository"); | ||||
|                 logger.debug("Had " + count + " commits overall in repository"); | ||||
| 
 | ||||
|                 logs = git.log() | ||||
|                         // for all log.all() | ||||
| @ -53,10 +58,10 @@ public class Log { | ||||
|                         .call(); | ||||
|                 count = 0; | ||||
|                 for (RevCommit rev : logs) { | ||||
|                     //System.out.println("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); | ||||
|                     logger.trace("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); | ||||
|                     count++; | ||||
|                 } | ||||
|                 System.out.println("Had " + count + " commits on README.md"); | ||||
|                 logger.debug("Had " + count + " commits on README.md"); | ||||
| 
 | ||||
|                 logs = git.log() | ||||
|                         // for all log.all() | ||||
| @ -64,10 +69,10 @@ public class Log { | ||||
|                         .call(); | ||||
|                 count = 0; | ||||
|                 for (RevCommit rev : logs) { | ||||
|                     //System.out.println("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); | ||||
|                     logger.trace("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */); | ||||
|                     count++; | ||||
|                 } | ||||
|                 System.out.println("Had " + count + " commits on pom.xml"); | ||||
|                 logger.debug("Had " + count + " commits on pom.xml"); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -13,5 +13,6 @@ public class PorcelainUnitTest { | ||||
|         CreateAndDeleteTag.main(null); | ||||
| 
 | ||||
|         Log.main(null); | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										5
									
								
								libraries-testing/src/test/resources/logback.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								libraries-testing/src/test/resources/logback.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <configuration> | ||||
|     <logger name="org.dbunit" level="INFO" /> | ||||
| </configuration> | ||||
| 
 | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user