Question: String - based Log Analyzer Task: Write a function log _ analyzer ( log _ string ) that analyzes a given string representing log data.

String-based Log Analyzer
Task: Write a function log_analyzer(log_string) that analyzes a given string representing log data. The function should count the number of error
messages and return this count. An error message is identified by the keyword "ERROR" at the beginning of a line. The log data will be provided
as a single string where lines are separated by newline characters (In).
def log_analyzer(log_string):
# your implementation here
pass
# # Student Test Cases
# log_sample_1= "INF0: User logged in
ERROR: Invalid password
INF0: Security alert
ERROR: System overload"
# log_sample_2= "INF0: Data updated
ERROR: Connection failed"
# log_sample_3= "WARNING: Low disk space
INF0: File saved"
# assert log_analyzer(log_sample_1)==2
# assert log_analyzer(log_sample_2)==1
# assert log_analyzer(log_sample_3)==0
* For each of the functions below, at least two examples are provided to test your functions.
functions will be tested both with examples provided in each question and with extra examples.
Each function has to be documented with docstrings . In particular, each function has to have docstrings that specify: a. description about what the function does (while mentioning parameter names) b. preconditions, if any
 String-based Log Analyzer Task: Write a function log_analyzer(log_string) that analyzes a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!