Skip to content

Allow relative paths for logfile configuration #28

@derek-shnosh

Description

@derek-shnosh

Currently, if a relative path like ~/.meraki-cli/meraki-cli.log is defined, meraki-cli will attempt to append logging data to the current path plus the relative path. E.g., If I am in /home/ds/OneDrive, meraki-cli attempts to write to a log file at /home/ds/OneDrive/~/.meraki-cli/meraki-cli.log


{
    "apiKey": "<OMIT>",
    "debug": 0,
    "logfile": "~/.meraki-cli/meraki-cli.log"
}
$ meraki -j networks getNetworkDevices --networkId <OMIT>
Traceback (most recent call last):
  File "/home/ds/.local/bin/meraki", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/ds/.local/share/pipx/venvs/meraki-cli/lib/python3.12/site-packages/meraki_cli/__main__.py", line 1228, in main
    log, meraki_log = _configure_logging(args)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ds/.local/share/pipx/venvs/meraki-cli/lib/python3.12/site-packages/meraki_cli/__main__.py", line 321, in _configure_logging
    fileHandler = logging.FileHandler(parsed_args.logfile)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/logging/__init__.py", line 1231, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "/usr/lib/python3.12/logging/__init__.py", line 1263, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/ds/OneDrive/~/.meraki-cli/meraki-cli.log'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions