fb pixel

Introduction to Python

  • Profound Academy

    • Status
      • 1
        Input and Output
      • 2
        Variables and Integer Arithmetic
      • 3
        Conditional Operators
      • 4
        Advanced Conditions - Nesting
      • 5
        Types and Variables
      • 6
        Strings
      • 7
        Lists
      • 8
        For Loops
      • 9
        While Loops
      • 10
        continue, break, while...else
      • 11
        String and List methods
      • 12
        Nested Loops
      • 13
        List Comprehension
      • 14
        Tuples and Sets
      • 15
        dict
      • 16
        Functions
      • 17
        Functions 2
      • 18
        Lambda and higher-order functions
      • 19
        Files

  • Clean the logs

    The log files usually contain timestamps that indicate when the event happened and log levels (INFO, TRACE, ERROR). Your task is to clean up that information so that only the important piece is present.
    log.txt contains the dirty logs.
    The program should print the clean logs in the output.
    log.txt
    03/22 08:51:01 INFO   :...locate_configFile: Specified configuration file: /u/user10/rsvpd1.conf
    03/22 08:51:01 INFO   :.main: Using log level 511
    03/22 08:51:01 INFO   :..settcpimage: Get TCP images rc - EDC8112I Operation not supported on socket.
    03/22 08:51:01 INFO   :..settcpimage: Associate with TCP/IP image name = TCPCS
    03/22 08:51:02 INFO   :..reg_process: registering process with the system
    03/22 08:51:02 INFO   :..reg_process: attempt OS/390 registration
    03/22 08:51:02 INFO   :..reg_process: return from registration rc=0
    03/22 08:51:06 TRACE  :...read_physical_netif: Home list entries returned = 7
    03/22 08:51:06 INFO   :...read_physical_netif: index #0, interface VLINK1 has address 129.1.1.1, ifidx 0
    03/22 08:51:06 INFO   :...read_physical_netif: index #1, interface TR1 has address 9.37.65.139, ifidx 1
    03/22 08:51:06 INFO   :...read_physical_netif: index #2, interface LINK11 has address 9.67.100.1, ifidx 2
    03/22 08:51:06 INFO   :...read_physical_netif: index #3, interface LINK12 has address 9.67.101.1, ifidx 3
    
    Output
    :...locate_configFile: Specified configuration file: /u/user10/rsvpd1.conf
    :.main: Using log level 511
    :..settcpimage: Get TCP images rc - EDC8112I Operation not supported on socket.
    :..settcpimage: Associate with TCP/IP image name = TCPCS
    :..reg_process: registering process with the system
    :..reg_process: attempt OS/390 registration
    :..reg_process: return from registration rc=0
    :...read_physical_netif: Home list entries returned = 7
    :...read_physical_netif: index #0, interface VLINK1 has address 129.1.1.1, ifidx 0
    :...read_physical_netif: index #1, interface TR1 has address 9.37.65.139, ifidx 1
    :...read_physical_netif: index #2, interface LINK11 has address 9.67.100.1, ifidx 2
    :...read_physical_netif: index #3, interface LINK12 has address 9.67.101.1, ifidx 3
    Example log taken from https://www.ibm.com/docs/en/zos/2.2.0?topic=problems-example-log-file
     
    To check your solution you need to sign in
    Sign in to continue