I need a good design to implement a text file reader,
Suppose, In my application, I have the following config file as a JSON file.
[
{
"file_path":"/home/abc/textfile1.log",
"app_name":"textfile1",
"users":[
{
"name":"RTS",
"email":"RTS@example.com",
"phone":"789",
"notificationTypes":"email,sms"
},
{
"name":"XYZ",
"email":"XYZ@example.com",
"phone":"456",
"notificationTypes":"email"
}
]
},
{
"file_path":"/home/pqr/textfile2.log",
"app_name":"textfile2",
"users":[
{
"name":"ABC",
"email":"ABC@example.com",
"phone":"123",
"notificationTypes":"email,sms"
}
]
}
]
This application should able to read separate log files. According to the above JSON, there are two text files called textfile1
and textfile2
. what I need to do is, suppose each log file, text content consists as follows,
2010-12-10 ERROR Test
2010-12-10 WARNING Test
2010-12-10 VERBOSE Test
2010-12-10 WARNING Test
2010-12-10 ERROR Test
once the application reading the text file, if there is an error log, I need to send the error message to a particular user.
as example,
{
"file_path":"/home/pqr/textfile2.log",
"app_name":"textfile2",
"users":[
{
"name":"ABC",
"email":"ABC@example.com",
"phone":"123",
"notificationTypes":"email,sms"
}
]
}
once app reading the textfile2
and if there is any error log, I need to send an error message to email and phone, I need a good design to resolve this problem. How can I apply SOLID principles here, can anyone suggest me a good design by sample pseudo-code or class diagram.
Aucun commentaire:
Enregistrer un commentaire