Sample: Migration Action Logging
This sample illustrates how to implement migration action logging, capturing the statuses of migration actions upon completion.
Migration Action Completed Hook Class
To log migration action statuses in Python, you can utilize the following hook class:
import logging
from tableau_migration import(
MigrationActionCompletedHookBase,
IMigrationActionResult
)
class LogMigrationActionsHook(MigrationActionCompletedHookBase):
def __init__(self) -> None:
super().__init__()
# Create a logger for this class
self._logger = logging.getLogger(__name__)
def execute(self, ctx: IMigrationActionResult) -> IMigrationActionResult:
if(ctx.success):
self._logger.info("Migration action completed successfully.")
else:
all_errors = "\n".join(ctx.errors)
self._logger.warning("Migration action completed with errors:\n%s", all_errors)
return None
Registration
plan_builder.hooks.add(LogMigrationActionsHookForUsers)
plan_builder.hooks.add(LogMigrationActionsHookForGroups)
See hook registration for more details.