You are part of a team that’s working on a new state-of-the-art project management system. The system monitors the execution of all programs that run on the same server and handles different critical and warning errors that may occur during runtime. Each found error is logged in a special log file and has the following format:
{"Project": ["ProjectName"], "Type": ["ErrorType"], "Message": ["ErrorMessage"]}
Your task is to create a module that monitors the error log and prepares a daily report for the errors that were encountered.
You will receive the errors through the console each on a separate line. The input stops when the string “END” is received. The error type can by either “Critical”, or “Warning”. The string value for each parameter may contain any ASCII character other than null. The complete report should consist of sub-reports each for each of the projects that were experiencing problems. Each sub-report should have the following format:
ProjectName:
Total Errors: {total number of errors}
Critical: {total number of critical errors}
Warnings: {total number of warnings}
Critical Messages:
--->{message of critical error No. 1}
--->{message of critical error No.2}
…
Warning Messages:
--->{message of warning No. 1}
--->{message of warning No. 2}
…
The sub-reports should be separated by an empty line. There shouldn’t be any empty lines after the last sub-report. Print the reports by total number of errors in descending order. If two reports have the same number of total errors, print them in the alphabetical order of their names. The critical and warning messages should be printed by the number of characters in the message string in ascending order. If two messages have the same number of characters, print them in alphabetical order. If there are no warning, or error messages, print None, in the place of the messages list.
Input· The input should be read from the console.
· Each error will be on a separate line and in the format described.
· When the string “END” is received, the input stops.
Output· The output should be printed on the console.
· The output should be the complete report, printed in the described format.
· The sub-reports should be separated by an empty line.
· The “arrows” in the critical/warning messages list, is made up of three “-” and one “>” symbols.
Constraints· The number of errors will be in the range: [1 … 100].
· The input lines will always be in the format described.
· Each line will always have Project, Type and Messages parameters.
· The value of each parameter may contain any ASCII character other than null.
Examples
Input |
Output |
{"Project": ["Project1"], "Type": ["Critical"], "Message": ["File not found"]} {"Project": ["Project2"], "Type": ["Critical"], "Message": ["IndexOutOfBoundsException"]} {"Project": ["Project2"], "Type": ["Critical"], "Message": ["Null Pointer"]} {"Project": ["Project1"], "Type": ["Critical"], "Message": ["File not found"]} {"Project": ["Project2"], "Type": ["Warning"], "Message": ["Low disk space"]} {"Project": ["Project2"], "Type": ["Critical"], "Message": ["AndexOutOfBoundsException"]} END |
Project2: Total Errors: 4 Critical: 3 Warnings: 1 Critical Messages: --->Null Pointer --->AndexOutOfBoundsException --->IndexOutOfBoundsException Warning Messages: --->Low disk space
Project1: Total Errors: 2 Critical: 2 Warnings: 0 Critical Messages: --->File not found --->File not found Warning Messages: --->None |
Input |
Output |
{"Project": ["KBryant"], "Type": ["Warning"], "Message": ["Retirement pending"]} {"Project": ["KBryant"], "Type": ["Critical"], "Message": ["6th ring not found"]} {"Project": ["DRose"], "Type": ["Warning"], "Message": ["Injury may occur"]} END |
KBryant: Total Errors: 2 Critical: 1 Warnings: 1 Critical Messages: --->6th ring not found Warning Messages: --->Retirement pending
DRose: Total Errors: 1 Critical: 0 Warnings: 1 Critical Messages: --->None Warning Messages: --->Injury may occur |