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

Improve log (-l) option to accept Putty like &Y, &M &D &T "variables" #546

Closed
ila225 opened this issue Apr 29, 2016 · 6 comments
Closed

Comments

@ila225
Copy link

ila225 commented Apr 29, 2016

Hi,

Working with Mintty is awesome, it is my current terminal of choice and everything works with Cygwin as I currently need, except for one thing: terminal logging.

More often than not I trace back previous activities and logging is imperative for my sessions. However, Mintty only accepts a %d option for the process number, which doesn't allow for much customization.

Therefore, I would like to request an improvement which is to allow "-l" to accept variables for Year, Month, Day, Time or Hour, Minute, Second and any additional variables you would see value to have so one could create unique log files given a certain string.

Something like: -l "log %Y%M%D_%H%M%S.log" is what I would suggest.

Alternatives I looked at:

  • script: creates a subshell and skips my .bash_profile settings
  • l=log\ $(date +%Y%m%d_%H%M%S).log followed by exec -l >> >(tee "$l") 2>> >(tee "$l") in .bash_profile does the trick, at the cost of two additional bash and tee processes (4 in total) plus the annoyance of not being in a terminal properly per say, thus having issues with "vi" and terminal size based utilities like "less" and "more"
  • currently using a mintty.cmd with mintty -l "%USERPROFILE%\Documents\Shell Logs\bash %date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.log" in it which works, but has the extra popup whenever I trigger it and is far from elegant

Thank you!

@mintty
Copy link
Owner

mintty commented Apr 29, 2016

I understand you basically want a timestamp. Rather than handling %Y etc individually, what about either a simpler or more generic option:

  • %D as a placeholder for a timestamp including milliseconds (2016-04-29_09:27:38.939)
  • a format string that is passed to the strftime() function

Also, I was thinking about an option to toggle logging within the mintty session from the popup menu (like in xterm); would that be useful, too?

@ila225
Copy link
Author

ila225 commented Apr 29, 2016

That would be perfect!

Although I personally don't like %D as a timestamp due to ":" being a special character in a few shells which adds escaping it, it achieves the main objective, and for someone getting started is simple and easy, thus great. But then when you add the possibility of strftime() that covers it all. I didn't want to ask for something like that as I wanted to keep it simple to implement but using strftime() format is actually simpler, great call!

And the menu option is the ultimate improvement. When I think of it:

  • Configuration options will probably end in .minttyrc configuration file:
    • Which is great as we don't have to pass a command line option
    • Prevents us from having to tinker with Windows Shortcuts, which are quite limited
    • Thus allowing those settings to take place no matter how you start mintty
    • Which also makes it a lot easier to use and set through the GUI
  • Using the GUI, you could easily code a mouse over option to show formatting options, easy info
  • Also increases exposure. I'm pretty sure about everybody checked the menu Options, but not that many checked the command line

Overall, just brilliant if you are able to implement it like you said. 😊

@mintty
Copy link
Owner

mintty commented Apr 29, 2016

Actually, the typical approach for a number of more special settings is that they can be configured in .minttyrc (and it can already, Log=...) but not in the Options menu, in order to keep that concise. See "Hidden settings" in the manual page.

@mintty
Copy link
Owner

mintty commented May 2, 2016

Released in 2.3.6. See manual page for details.

@mintty
Copy link
Owner

mintty commented Mar 11, 2017

With 2.7.5, logging can be toggled from extended context menu.

@ila225
Copy link
Author

ila225 commented Mar 12, 2017

Awesome! Gotta check it out Monday as soon as I'm back at work! Thank you!!!

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

No branches or pull requests

2 participants