Add logs for LdPreload action on success or failure

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
This commit is contained in:
Christophe Bedard 2020-03-07 13:56:13 -05:00
parent 3c02ef058c
commit 337d80c847

View file

@ -19,6 +19,7 @@ from typing import List
from typing import Optional
from typing import Union
from launch import logging
from launch.action import Action
from launch.actions import SetEnvironmentVariable
from launch.launch_context import LaunchContext
@ -43,14 +44,18 @@ class LdPreload(Action):
super().__init__(**kwargs)
self.__lib_name = lib_name
self.__set_env_action = None
self.__logger = logging.get_logger(__name__)
# Try to find lib
self.__lib_path = self.get_shared_lib_path(self.__lib_name)
# And create action if found
if self.__lib_path is not None:
self.__logger.debug(f'Shared library found at: {self.__lib_path}')
self.__set_env_action = SetEnvironmentVariable(
self.ENV_VAR_LD_PRELOAD,
self.__lib_path,
)
else:
self.__logger.warn(f'Could not find shared library: {self.__lib_name}')
def lib_found(self) -> bool:
return self.__set_env_action is not None