diff --git a/src/dir_wand/command_runner.py b/src/dir_wand/command_runner.py index b2401cf..5d65a7a 100644 --- a/src/dir_wand/command_runner.py +++ b/src/dir_wand/command_runner.py @@ -23,6 +23,9 @@ from dir_wand.logger import Logger from dir_wand.utils import swap_in_str +# Get the logger +logger = Logger() + class CommandRunner: """ @@ -75,7 +78,7 @@ def get_placeholders(self): for match in matches: self._placeholders.add(match) - @Logger().count("command") + @logger.count("command") def run_command(self, **swaps): """ Run the command. diff --git a/src/dir_wand/directory.py b/src/dir_wand/directory.py index 52c8015..a64e816 100644 --- a/src/dir_wand/directory.py +++ b/src/dir_wand/directory.py @@ -30,6 +30,9 @@ from dir_wand.logger import Logger from dir_wand.utils import swap_in_str +# Get the logger +logger = Logger() + class Directory: """ @@ -153,7 +156,7 @@ def unpack_contents(self): # Add the file to the files self.files.append(f) - @Logger().count("directory") + @logger.count("directory") def _make_dir_copy(self, path): """ Make a copy of the directory. diff --git a/src/dir_wand/file.py b/src/dir_wand/file.py index 04a69a8..c926b94 100644 --- a/src/dir_wand/file.py +++ b/src/dir_wand/file.py @@ -26,6 +26,9 @@ from dir_wand.logger import Logger from dir_wand.utils import swap_in_str +# Get the logger +logger = Logger() + class File: """ @@ -153,13 +156,13 @@ def get_placeholders(self): for match in matches: self._placeholders.add(match) - @Logger().count("file") + @logger.count("file") def _make_softlink_copy(self, path): """Make a copy of a softlink.""" link = os.readlink(self.path) os.symlink(link, path) - @Logger().count("file") + @logger.count("file") def _make_executable_copy(self, path): """Make a copy of an executable file.""" # Copy the file @@ -170,7 +173,7 @@ def _make_executable_copy(self, path): # Copy the permissions os.chmod(path, os.stat(path).st_mode) - @Logger().count("file") + @logger.count("file") def _make_simple_copy(self, path): """Make a simple copy of a file.""" # Copy the file @@ -178,7 +181,7 @@ def _make_simple_copy(self, path): with open(path, "wb") as new_file: new_file.write(file.read()) - @Logger().count("file") + @logger.count("file") def _make_copy_with_placeholders(self, path, **swaps): """ Make a copy of the file with the placeholders swapped out.