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

Add log-file-path option #600

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

qwer-lives
Copy link

Fixes #581

This adds an argument to specify the file where the logs will be written.

var dir = Path.GetDirectoryName(input);
var filename = Path.GetFileName(input);
var newName = OtherUtil.GetValidFileName(filename);
if (string.IsNullOrEmpty(newName))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary to support inputting relative paths or scenarios where only the filename is provided. With absolute path, should check whether the path is correct and maybe creating the folder if it does not exist.

Copy link
Author

@qwer-lives qwer-lives Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added support for relative paths. Path.GetFullPath() raises an exception if the path is not valid so that should be enough to ensure the path is correct. The folder is also created at Logger.InitLogFile() if it doesn't exist.

I tested it with a bunch of absolute and relative paths and it seems to be working (I could only test it in linux but C# Path should work for all platforms). Let me know if something is missing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Argument to specify log file
2 participants