-
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
solved task jv-logger #1070
base: master
Are you sure you want to change the base?
solved task jv-logger #1070
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea/* | ||
*.iml | ||
target/* | ||
logs/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,15 @@ | |
|
||
import mate.academy.exception.AuthenticationException; | ||
import mate.academy.model.User; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
public class AuthenticationServiceImpl implements AuthenticationService { | ||
private static final Logger logger = LogManager.getLogger(AuthenticationServiceImpl.class); | ||
|
||
@Override | ||
public User login(String login, String password) throws AuthenticationException { | ||
//TODO: add corresponding log message about method login was called | ||
logger.info("login method was called. Params: login = {}", login); | ||
User user = findByLogin(login); | ||
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. Ensure that the 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. Verify that the |
||
if (!user.getPassword().equals(password)) { | ||
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. Verify that the |
||
throw new AuthenticationException("Username or password are incorrect"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,15 @@ | |
import java.util.List; | ||
import mate.academy.model.Order; | ||
import mate.academy.model.Product; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
public class OrderServiceImpl implements OrderService { | ||
private static final Logger logger = LogManager.getLogger(OrderServiceImpl.class); | ||
|
||
@Override | ||
public Order completeOrder(Long userId) { | ||
// TODO: add log message about method completeOrder was called | ||
logger.info("method completeOrder was called. Params: userId = {}", userId); | ||
List<Product> products = getAllProductsFromShoppingCart(userId); | ||
Order order = new Order(products, userId); | ||
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. Ensure that the 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. Ensure that the |
||
// NOTE: In production ready code this order identifier should be generated by DB | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Configuration status="info"> | ||
<Appenders> | ||
<Console name="Console" target="SYSTEM_OUT"> | ||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> | ||
</Console> | ||
<File name ="LogToFile" filename="logs/app.log"> | ||
<PatternLayout> | ||
<Pattern>%d %p %c:%L %m%n</Pattern> | ||
</PatternLayout> | ||
</File> | ||
</Appenders> | ||
<Loggers> | ||
<Logger name ="mate.academy" level="info" additivity="false"> | ||
<AppenderRef ref="LogToFile"/> | ||
<AppenderRef ref="Console"/> | ||
</Logger> | ||
<Root level="error"> | ||
<AppenderRef ref="LogToFile"/> | ||
<AppenderRef ref="Console"/> | ||
</Root> | ||
</Loggers> | ||
</Configuration> |
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.
Ensure that the logger is configured with appenders for both File and Console as required by the task description .