
import asyncio
import command
import config
import logging
import protocol
import signal

LOG_FORMAT = "%(asctime)-15s %(name)-10s %(levelname)-8s %(message)s"
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)


def main():
    logger = logging.getLogger("pearbot")
    logger.info("PearBot started.")

    loop = asyncio.get_event_loop()
    client_config = config.get_config("irc")
    client = protocol.Protocol(**client_config)

    cmdhdl_config = config.get_config("cmd")
    # we don't need to remember this instance
    command.CommandHandler(client, **cmdhdl_config)

    def shutdown():
        logger.info("Shutdown signal received.")
        client.shutdown()
    loop.add_signal_handler(signal.SIGTERM, shutdown)

    logger.info("Running protocol activity.")
    task = client.run()
    loop.run_until_complete(task)
    logger.info("Protocol activity ceased.")
    logger.info("Exiting...")

if __name__ == "__main__":
    main()


import asyncio
import command
import config
import logging
import protocol
import signal

LOG_FORMAT = "{asctime} [{process}] {levelname}({name}): {message}"
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT, style="{")


def main():
    logger = logging.getLogger("pearbot")
    logger.info("PearBot started.")

    loop = asyncio.get_event_loop()
    client_config = config.get_config("irc")
    client = protocol.Protocol(**client_config)

    cmdhdl_config = config.get_config("cmd")
    # we don't need to remember this instance
    command.CommandHandler(client, **cmdhdl_config)

    def shutdown():
        logger.info("Shutdown signal received.")
        client.shutdown()
    loop.add_signal_handler(signal.SIGTERM, shutdown)

    logger.info("Running protocol activity.")
    task = client.run()
    loop.run_until_complete(task)
    logger.info("Protocol activity ceased.")
    logger.info("Exiting...")

if __name__ == "__main__":
    main()

Change log format (added PID)
Change log format (added PID)

  
  import asyncio
  import command
  import config
  import logging
  import protocol
  import signal
  
- LOG_FORMAT = "%(asctime)-15s %(name)-10s %(levelname)-8s %(message)s"
+ LOG_FORMAT = "{asctime} [{process}] {levelname}({name}): {message}"
- logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
+ logging.basicConfig(level=logging.INFO, format=LOG_FORMAT, style="{")
  
  
  def main():
      logger = logging.getLogger("pearbot")
      logger.info("PearBot started.")
  
      loop = asyncio.get_event_loop()
      client_config = config.get_config("irc")
      client = protocol.Protocol(**client_config)
  
      cmdhdl_config = config.get_config("cmd")
      # we don't need to remember this instance
      command.CommandHandler(client, **cmdhdl_config)
  
      def shutdown():
          logger.info("Shutdown signal received.")
          client.shutdown()
      loop.add_signal_handler(signal.SIGTERM, shutdown)
  
      logger.info("Running protocol activity.")
      task = client.run()
      loop.run_until_complete(task)
      logger.info("Protocol activity ceased.")
      logger.info("Exiting...")
  
  if __name__ == "__main__":
      main()
  
Change log format (added PID)
## Code Before:

import asyncio
import command
import config
import logging
import protocol
import signal

LOG_FORMAT = "%(asctime)-15s %(name)-10s %(levelname)-8s %(message)s"
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)


def main():
    logger = logging.getLogger("pearbot")
    logger.info("PearBot started.")

    loop = asyncio.get_event_loop()
    client_config = config.get_config("irc")
    client = protocol.Protocol(**client_config)

    cmdhdl_config = config.get_config("cmd")
    # we don't need to remember this instance
    command.CommandHandler(client, **cmdhdl_config)

    def shutdown():
        logger.info("Shutdown signal received.")
        client.shutdown()
    loop.add_signal_handler(signal.SIGTERM, shutdown)

    logger.info("Running protocol activity.")
    task = client.run()
    loop.run_until_complete(task)
    logger.info("Protocol activity ceased.")
    logger.info("Exiting...")

if __name__ == "__main__":
    main()

## Instruction:
Change log format (added PID)
## Code After:

import asyncio
import command
import config
import logging
import protocol
import signal

LOG_FORMAT = "{asctime} [{process}] {levelname}({name}): {message}"
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT, style="{")


def main():
    logger = logging.getLogger("pearbot")
    logger.info("PearBot started.")

    loop = asyncio.get_event_loop()
    client_config = config.get_config("irc")
    client = protocol.Protocol(**client_config)

    cmdhdl_config = config.get_config("cmd")
    # we don't need to remember this instance
    command.CommandHandler(client, **cmdhdl_config)

    def shutdown():
        logger.info("Shutdown signal received.")
        client.shutdown()
    loop.add_signal_handler(signal.SIGTERM, shutdown)

    logger.info("Running protocol activity.")
    task = client.run()
    loop.run_until_complete(task)
    logger.info("Protocol activity ceased.")
    logger.info("Exiting...")

if __name__ == "__main__":
    main()
