Skip to main content
FileManager is an internal static utility class in chromologger.utils.files_manager that handles all file and path operations used by the Logger. It is not part of the public __all__ export but may be useful for advanced use cases.

Import

FileManager is an internal utility. The Logger class is the recommended public API for all logging operations — use FileManager directly only when you need low-level file or path helpers outside of normal logging workflows.

Methods

All methods on FileManager are @staticmethod — no instantiation is required.

open_file(file_relative_path, mode='a', encoding='utf-8')

Resolves file_relative_path to an absolute path via get_abs_path(), then opens the file with Python’s built-in open().
str
required
Path to the target file. May be relative or absolute — it is always resolved to absolute internally before opening.
str
default:"'a'"
File open mode passed directly to open(). Defaults to append mode ('a'), matching the typical use-case of appending log lines.
str
default:"'utf-8'"
Character encoding passed to open(). Defaults to UTF-8.
Union[TextIOWrapper, None]
The open file object on success. Any exception raised during open() is re-raised to the caller — the method does not swallow errors silently. In practice, None is never returned because any failure path raises rather than returning.

write_plain_text_file(file_path, message)

Opens file_path via open_file() in append mode, writes str(message) to it, then closes the file. Used internally by Logger.__log() to write entries to the module’s own internal error log.
str
required
Path to the file to write to. Resolved to absolute by the underlying open_file() call.
str
required
The content to write. Converted to str via str(message) before writing, so any Python object may be passed.
Any exception raised during file opening or writing is re-raised to the caller. Unlike Logger.log(), this method does not apply a timestamp or log-level prefix — the caller is responsible for formatting the string.

get_abs_path(relative_path)

Returns the fully resolved absolute path of relative_path as a string, using pathlib.Path(relative_path).resolve().absolute().
str
required
The path to resolve. Relative paths are resolved against the current working directory; absolute paths pass through unchanged.
str
The absolute, resolved path string (no trailing separator, symlinks resolved).
Example

get_abs_dir(relative_path)

Returns the absolute path of the parent directory of relative_path. Internally calls pathlib.Path(relative_path).resolve().absolute().parent. Used by Logger.__init__() to determine self.caller_script — the directory of the script that created the logger.
str
required
A path to any file or directory. The method resolves it and returns the parent directory, not the path itself.
str
Absolute path of the parent directory as a string.
Example

join_paths(base_path, *others_paths)

Joins base_path with one or more additional path components using pathlib.Path.joinpath(), then resolves the combined path to an absolute string.
str
required
The root portion of the path. Resolved to absolute before joining.
str
required
One or more path components to append to base_path. Passed directly to pathlib.Path.joinpath().
str
The fully resolved, absolute joined path as a string.
Example