python
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
file_handler = logging.FileHandler('fabric.log')
file_handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
logger.info('This is an informational message.')
logger.warning('This is a warning message.')
logger.error('This is an error message.')
python
from fabric import task
@task
def my_task(c):
c.debug('This is a debug message.')
c.info('This is an informational message.')
c.warning('This is a warning message.')
c.error('This is an error message.')
c.fatal('This is a fatal message.')
c.debug(f'Input parameters: {c.values}')
c.debug(f'Result: {result}')
python
from fabric import task
@task
def my_task(c, input_param):
assert isinstance(input_param, str), "Input parameter must be a string."
python
from fabric import task
@task
def my_task(c):
result = some_function()
print(f'Result: {result}')
python
import pdb
from fabric import task
@task
def my_task(c):
pdb.set_trace()