-
Notifications
You must be signed in to change notification settings - Fork 1k
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
logger configured #1052
base: master
Are you sure you want to change the base?
logger configured #1052
Conversation
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.
Thank you for your hard work on this pull request! 😊 While your code meets most of the task requirements, there are a few critical issues that need to be addressed before we can approve it:
-
Logger Configuration: The logger needs to be configured with appenders for both File and Console, as per the task requirements. This is crucial for ensuring that logging is handled correctly.
-
Sensitive Information Logging: Be cautious about logging sensitive information, such as usernames. Ensure that your logging practices comply with your application's privacy and security policies.
-
.gitignore File: The
.gitignore
file should be updated to correctly ignore theapp.log
file. The line should belogs/app.log
instead of/logs/app.log
.
Please address these issues, and feel free to reach out if you have any questions or need further assistance. Once these changes are made, we can proceed with approving your pull request. Keep up the great work! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
.gitignore
Outdated
@@ -1,3 +1,4 @@ | |||
.idea/* | |||
*.iml | |||
target/* | |||
/logs/app.log |
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.
The line /logs/app.log
should be written without the leading slash to ignore the app.log
file in the logs
directory relative to the repository root. It should be logs/app.log
instead.
public static void main(String[] args) { | ||
AuthenticationService authenticationService = new AuthenticationServiceImpl(); | ||
User user; | ||
try { | ||
user = authenticationService.login("bob", "1234"); | ||
} catch (AuthenticationException e) { | ||
e.printStackTrace(); | ||
logger.error("Authentication failed for user 'bob'. Reason: {}", e.getMessage()); |
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.
Be cautious when logging sensitive information such as usernames or passwords. In this case, logging the username 'bob' might be acceptable, but ensure that no sensitive data like passwords are logged.
@Override | ||
public User login(String login, String password) throws AuthenticationException { | ||
//TODO: add corresponding log message about method login was called | ||
logger.info("Method login was called for user with login: {}", login); |
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.
Be cautious when logging sensitive information such as usernames. Ensure that logging the username is compliant with your application's privacy and security policies.
@Override | ||
public Order completeOrder(Long userId) { | ||
// TODO: add log message about method completeOrder was called | ||
logger.info("Method completeOrder was called for userId: {}", userId); |
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.
Be cautious when logging user identifiers. Ensure that logging user IDs is compliant with your application's privacy and security policies.
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.
Great job on addressing some of the issues in your code! 🎉 While the .gitignore
file has been correctly updated, there are still a few critical points to focus on:
-
Logger Configuration: Ensure that the logger is configured with appenders for both File and Console, as this is a critical requirement for the task.
-
Sensitive Information Logging: Be cautious about logging sensitive information such as usernames and user IDs. Consider using anonymized data to comply with privacy and security policies.
These improvements are essential for the functionality and security of your application. Keep up the good work and use this feedback to enhance your coding skills. Remember, addressing these issues will help you avoid similar problems in the future. Keep learning and improving! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; |
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.
The logger is imported and used, but ensure that it is configured with appenders for both File and Console as per the task requirements .
public static void main(String[] args) { | ||
AuthenticationService authenticationService = new AuthenticationServiceImpl(); | ||
User user; | ||
try { | ||
user = authenticationService.login("bob", "1234"); | ||
} catch (AuthenticationException e) { | ||
e.printStackTrace(); | ||
logger.error("Authentication failed for user 'bob'. Reason: {}", e.getMessage()); |
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.
Be cautious about logging sensitive information like usernames. Consider logging a user ID or anonymized identifier instead to comply with privacy and security policies .
@Override | ||
public User login(String login, String password) throws AuthenticationException { | ||
//TODO: add corresponding log message about method login was called | ||
logger.info("Method login was called for user with login: {}", login); |
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.
Logging the username directly can be a security risk. Consider logging anonymized data or a user ID instead to comply with privacy and security policies.
@Override | ||
public Order completeOrder(Long userId) { | ||
// TODO: add log message about method completeOrder was called | ||
logger.info("Method completeOrder was called for userId: {}", userId); |
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.
Logging user IDs can be sensitive. Ensure that this practice complies with your application's privacy and security policies.
@@ -24,7 +29,7 @@ | |||
Product macBook = new Product("MacBook Air 2020", BigDecimal.valueOf(1399)); | |||
Product xiaomi = new Product("Xiaomi 12", BigDecimal.valueOf(499)); | |||
List<Product> products = List.of(iphone, macBook, xiaomi); | |||
// TODO: add log message about successful fetched data from DB | |||
logger.info("Method getAllProductsFromShoppingCart was called for userId: {}", userId); |
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.
Logging user IDs can be sensitive. Ensure that this practice complies with your application's privacy and security policies.
@Override | ||
public User login(String login, String password) throws AuthenticationException { | ||
//TODO: add corresponding log message about method login was called | ||
logger.info("Method login was called for user with login: {}", login); |
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.
it's better to use debug level when methods are called
No description provided.