Skip to content

Commit

Permalink
make log output less noisey
Browse files Browse the repository at this point in the history
  • Loading branch information
JSCU-CNI committed Sep 19, 2024
1 parent c5bf1ed commit 422884c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit 422884c

Please sign in to comment.