-
Notifications
You must be signed in to change notification settings - Fork 1.1k
done #1255
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
base: master
Are you sure you want to change the base?
done #1255
Changes from 1 commit
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,14 +2,18 @@ | |
|
|
||
| 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("Method login was called. Params = {}", login); | ||
| User user = findByLogin(login); | ||
| 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. This log message doesn't include the |
||
| throw new AuthenticationException("Username or password are incorrect"); | ||
| logger.error("Username or password are incorrect : login = {}", user.getLogin()); | ||
| } | ||
| return user; | ||
| } | ||
|
|
||
| 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="LogToConsole" 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="LogToConsole"/> | ||
| </Logger> | ||
| <Root level="info"> | ||
| <AppenderRef ref="LogToFile"/> | ||
| <AppenderRef ref="LogToConsole"/> | ||
| </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.
The log message is generic. According to checklist item #4, include the userId parameter to make it informative:
logger.info("Method completeOrder was called. userId={}", userId);