Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. Devise an interview strategy from the interviewers point of view

Answered: 1 week ago