-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK-320: Replace System.out.println with logger #252
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c831c53
Replace System.out.println with logger
wikumChamith f4a1d7f
SDK-320: Replace System.out.println with logger
wikumChamith f16799c
SDK-320: Replace System.out.println with logger
wikumChamith ebbabe8
SDK-320: Replace System.out.println with logger
wikumChamith d9f58ed
SDK-320: Replace System.out.println with logger
wikumChamith 7e7a5eb
SDK-320: Replace System.out.println with logger
wikumChamith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
import org.apache.maven.model.io.xpp3.MavenXpp3Writer; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.openmrs.maven.plugins.utility.SDKConstants; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
|
@@ -54,7 +56,7 @@ public class Server extends BaseSdkProperties { | |
private static final String OLD_PROPERTIES_FILENAME = "backup.properties"; | ||
public static final String OWA_DIRECTORY = "owa"; | ||
|
||
private static final String CANNOT_CREATE_LINK_MSG = "\nCannot create a link at %s due to:\n%s\n" + | ||
private static final String CANNOT_CREATE_LINK_MSG = "\nCannot create a link at {} due to:\n{}\n" + | ||
"The project will be built in random order.\n" + | ||
"Please try running the command as an administrator.\n"; | ||
|
||
|
@@ -76,6 +78,8 @@ public class Server extends BaseSdkProperties { | |
|
||
private boolean interactiveMode; | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(Server.class); | ||
|
||
public static class ServerBuilder { | ||
private final Server server = new Server(); | ||
public ServerBuilder(Server server){ | ||
|
@@ -333,18 +337,17 @@ private boolean linkProject(Project project) { | |
if (Files.isSymbolicLink(linkPath)) { | ||
try { | ||
if (!Files.isSameFile(Paths.get(project.getPath()), linkPath)) { | ||
System.out.println("\nDeleting a link at " + link.getAbsolutePath() + " as it points to a different location."); | ||
logger.info("\nDeleting a link at {} as it points to a different location.", link.getAbsolutePath()); | ||
Files.delete(linkPath); | ||
} else { | ||
return true; | ||
} | ||
} catch (IOException e) { | ||
System.out.printf((CANNOT_CREATE_LINK_MSG) + "%n", link.getAbsolutePath(), e.getMessage()); | ||
logger.error(CANNOT_CREATE_LINK_MSG, link.getAbsolutePath(), e.getMessage()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is usually great to pass the exception object at the end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made the changes |
||
return false; | ||
} | ||
} else { | ||
System.out.printf((CANNOT_CREATE_LINK_MSG) + "%n", link.getAbsolutePath(), | ||
"The file or directory already exists!\nPlease delete it manually and try again."); | ||
logger.error(CANNOT_CREATE_LINK_MSG, link.getAbsolutePath(), "The file or directory already exists!\nPlease delete it manually and try again."); | ||
return false; | ||
} | ||
} | ||
|
@@ -353,7 +356,7 @@ private boolean linkProject(Project project) { | |
try { | ||
Files.createSymbolicLink(linkPath, Paths.get(project.getPath())); | ||
} catch (IOException e) { | ||
System.out.printf((CANNOT_CREATE_LINK_MSG) + "%n", link.getAbsolutePath(), e.getMessage()); | ||
logger.error(CANNOT_CREATE_LINK_MSG, link.getAbsolutePath(), e.getMessage()); | ||
return false; | ||
} | ||
} | ||
|
@@ -456,7 +459,7 @@ private void unlinkProject(Project project) { | |
try { | ||
Files.deleteIfExists(Paths.get(link.getAbsolutePath())); | ||
} catch (IOException e) { | ||
System.out.println("\nCould not delete link at " + link.getAbsolutePath()); | ||
logger.error("\nCould not delete link at {}", link.getAbsolutePath()); | ||
} | ||
} | ||
|
||
|
@@ -868,7 +871,7 @@ public void deleteServerTmpDirectory() { | |
try { | ||
FileUtils.deleteDirectory(tmpDirectory); | ||
} catch (IOException e) { | ||
System.out.println("Could not delete tmp directory"); | ||
logger.error("Could not delete tmp directory"); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the first parameter be the exception message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkayiwa I changed this