1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-17 21:27:08 +00:00

mac: activate logging when started from the bundle

this creates a default log for the last mpv run when started from the
bundle. that way one can get a log of what happened even after an issue
occurred. also add a menu entry under Help to show the current log, but
only when the bundle is used.

Fixes #7396
Fixes #2547
This commit is contained in:
der richter 2020-01-30 14:32:31 +01:00
parent b7b8a772f2
commit 2607a2b892
4 changed files with 50 additions and 7 deletions

View File

@ -31,9 +31,11 @@ differes from your own.
### Log file ### Log file
Make a log file made with -v -v or --log-file=output.txt, paste it to Make a log file made with -v -v or --log-file=output.txt. If you use the Bundle
https://0x0.st/ or attach it to the github issue, and replace this text with a from a version later than 0.32 a default log is created for your last run at
link to it. ~/Library/Logs/mpv.log. You can jump to that file via the Help > Show log File…
menu. Paste the log to https://0x0.st/ or attach it to the github issue, and
replace this text with a link to it.
In the case of a crash please provide the macOS Crash Report (Backtrace). In the case of a crash please provide the macOS Crash Report (Backtrace).

View File

@ -652,6 +652,9 @@ Program Behavior
can be raised via ``--msg-level`` (the option cannot lower it below the can be raised via ``--msg-level`` (the option cannot lower it below the
forced minimum log level). forced minimum log level).
A special case is the macOS bundle, it will create a log file at
``~/Library/Logs/mpv.log`` by default.
``--config-dir=<path>`` ``--config-dir=<path>``
Force a different configuration directory. If this is set, the given Force a different configuration directory. If this is set, the given
directory is used to load configuration files, and all other configuration directory is used to load configuration files, and all other configuration

View File

@ -1 +1,2 @@
player-operation-mode=pseudo-gui player-operation-mode=pseudo-gui
log-file=~/Library/Logs/mpv.log

View File

@ -594,6 +594,15 @@
@"key" : @"", @"key" : @"",
@"target" : self, @"target" : self,
@"url" : @"https://github.com/mpv-player/mpv/issues/new/choose" @"url" : @"https://github.com/mpv-player/mpv/issues/new/choose"
}],
[NSMutableDictionary dictionaryWithDictionary:@{
@"name" : @"Show log File…",
@"action" : @"showFile:",
@"key" : @"",
@"target" : self,
@"file" : @"~/Library/Logs/mpv.log",
@"alertTitle" : @"No log File found.",
@"alertText" : @"You deactivated logging for the Bundle."
}] }]
] ]
} }
@ -609,6 +618,7 @@
{ {
NSMenu *mainMenu = [[NSMenu alloc] initWithTitle:@"MainMenu"]; NSMenu *mainMenu = [[NSMenu alloc] initWithTitle:@"MainMenu"];
[NSApp setServicesMenu:[[NSMenu alloc] init]]; [NSApp setServicesMenu:[[NSMenu alloc] init]];
NSString* bundle = [[[NSProcessInfo processInfo] environment] objectForKey:@"MPVBUNDLE"];
for(id mMenu in menuTree) { for(id mMenu in menuTree) {
NSMenu *menu = [[NSMenu alloc] initWithTitle:mMenu[@"name"]]; NSMenu *menu = [[NSMenu alloc] initWithTitle:mMenu[@"name"]];
@ -618,17 +628,25 @@
[mainMenu setSubmenu:menu forItem:mItem]; [mainMenu setSubmenu:menu forItem:mItem];
for(id subMenu in mMenu[@"menu"]) { for(id subMenu in mMenu[@"menu"]) {
NSString *name = subMenu[@"name"];
NSString *action = subMenu[@"action"];
#if HAVE_MACOS_TOUCHBAR #if HAVE_MACOS_TOUCHBAR
if ([subMenu[@"action"] isEqual:@"toggleTouchBarCustomizationPalette:"]) { if ([action isEqual:@"toggleTouchBarCustomizationPalette:"]) {
if (![NSApp respondsToSelector:@selector(touchBar)]) if (![NSApp respondsToSelector:@selector(touchBar)])
continue; continue;
} }
#endif #endif
if ([subMenu[@"name"] isEqual:@"separator"]) {
if ([name isEqual:@"Show log File…"] && ![bundle isEqual:@"true"]) {
continue;
}
if ([name isEqual:@"separator"]) {
[menu addItem:[NSMenuItem separatorItem]]; [menu addItem:[NSMenuItem separatorItem]];
} else { } else {
NSMenuItem *iItem = [menu addItemWithTitle:subMenu[@"name"] NSMenuItem *iItem = [menu addItemWithTitle:name
action:NSSelectorFromString(subMenu[@"action"]) action:NSSelectorFromString(action)
keyEquivalent:subMenu[@"key"]]; keyEquivalent:subMenu[@"key"]];
[iItem setTarget:subMenu[@"target"]]; [iItem setTarget:subMenu[@"target"]];
[subMenu setObject:iItem forKey:@"menuItem"]; [subMenu setObject:iItem forKey:@"menuItem"];
@ -754,6 +772,25 @@
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]]; [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
} }
- (void)showFile:(NSMenuItem *)menuItem
{
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSMutableDictionary *mItemDict = [self getDictFromMenuItem:menuItem];
NSString *file = [mItemDict[@"file"] stringByExpandingTildeInPath];
if ([fileManager fileExistsAtPath:file]){
NSURL *url = [NSURL fileURLWithPath:file];
NSArray *urlArray = [NSArray arrayWithObjects:url, nil];
[workspace activateFileViewerSelectingURLs:urlArray];
return;
}
[self alertWithTitle:mItemDict[@"alertTitle"]
andText:mItemDict[@"alertText"]];
}
- (void)alertWithTitle:(NSString *)title andText:(NSString *)text - (void)alertWithTitle:(NSString *)title andText:(NSString *)text
{ {
NSAlert *alert = [[NSAlert alloc] init]; NSAlert *alert = [[NSAlert alloc] init];