Describe how you would write a script to monitor system logs and trigger automated alerts or self-healing actions when specific errors occur.