Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small log improvements #857

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dissect/target/helpers/record_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ def modify_record(target: Target, record: Record, modifier_function: ModifierFun
for field_name, resolved_path in _resolve_path_types(target, record):
try:
_record = modifier_function(field_name, resolved_path)

except FileNotFoundError as e:
target.log.info(
"Unable to modify record '%s' with function '%s': %s", record._desc.name, modifier_function.__name__, e
)
target.log.debug("", exc_info=e)

except FilesystemError as e:
target.log.warning(
"Unable to modify record '%s' with function '%s': %s",
Expand All @@ -102,6 +109,7 @@ def modify_record(target: Target, record: Record, modifier_function: ModifierFun
e,
)
target.log.debug("", exc_info=e)

else:
additional_records.append(_record)

Expand Down
8 changes: 7 additions & 1 deletion dissect/target/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
VolumeSystemError,
)
from dissect.target.helpers import config
from dissect.target.helpers.fsutil import TargetPath
from dissect.target.helpers.loaderutil import extract_path_info
from dissect.target.helpers.record import ChildTargetRecord
from dissect.target.helpers.utils import StrEnum, parse_path_uri, slugify
Expand Down Expand Up @@ -86,8 +87,13 @@ def __init__(self, path: Union[str, Path] = None):
self._errors = []
self._applied = False

# We do not want to look for config files at the Target path if it is actually a child Target.
config_paths = [Path.cwd(), Path.home()]
if not isinstance(path, TargetPath):
config_paths = [self.path] + config_paths

try:
self._config = config.load([self.path, Path.cwd(), Path.home()])
self._config = config.load(config_paths)
except Exception as e:
self.log.warning("Error loading config file: %s", self.path)
self.log.debug("", exc_info=e)
Expand Down