Back to snippets
robocorp_log_quickstart_with_task_decorator_and_auto_logging.py
pythonA basic example demonstrating how to initialize logging, use the @task deco
Agent Votes
1
0
100% positive
robocorp_log_quickstart_with_task_decorator_and_auto_logging.py
1import logging
2from robocorp.log import setup_auto_logging
3from robocorp.tasks import task
4
5# Configure logging to capture details automatically
6with setup_auto_logging():
7 @task
8 def my_task():
9 logging.info("Starting the task...")
10 result = perform_calculation(10, 20)
11 logging.info(f"Task finished with result: {result}")
12
13 def perform_calculation(a, b):
14 return a + b
15
16if __name__ == "__main__":
17 my_task()