mirror of
https://github.com/mpv-player/mpv
synced 2025-04-15 16:01:15 +02:00
macosx_finder_args: use a custom logfile instead of system.log
Change the macosx_finder_args function so that when mplayer2 is invoked from the Finder in a Mac application bundle, it redirects the output to ~/Library/Logs/mplayer2.log instead of cluttering the global system.log. This doesn't affect terminal use which keeps writing to stdout and stderr.
This commit is contained in:
parent
19458020a6
commit
ae0a38ddf8
@ -24,6 +24,7 @@
|
|||||||
static play_tree_t *files = NULL;
|
static play_tree_t *files = NULL;
|
||||||
|
|
||||||
void macosx_wait_fileopen_events(void);
|
void macosx_wait_fileopen_events(void);
|
||||||
|
void macosx_redirect_output_to_logfile(const char *filename);
|
||||||
bool psn_matches_current_process(char *psn_arg_to_check);
|
bool psn_matches_current_process(char *psn_arg_to_check);
|
||||||
|
|
||||||
@interface FileOpenDelegate : NSObject
|
@interface FileOpenDelegate : NSObject
|
||||||
@ -59,6 +60,16 @@ void macosx_wait_fileopen_events()
|
|||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void macosx_redirect_output_to_logfile(const char *filename)
|
||||||
|
{
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
NSString *log_path = [NSHomeDirectory() stringByAppendingPathComponent:
|
||||||
|
[@"Library/Logs/" stringByAppendingFormat:@"%s.log", filename]];
|
||||||
|
freopen([log_path fileSystemRepresentation], "a", stdout);
|
||||||
|
freopen([log_path fileSystemRepresentation], "a", stderr);
|
||||||
|
[pool release];
|
||||||
|
}
|
||||||
|
|
||||||
bool psn_matches_current_process(char *psn_arg_to_check)
|
bool psn_matches_current_process(char *psn_arg_to_check)
|
||||||
{
|
{
|
||||||
ProcessSerialNumber psn;
|
ProcessSerialNumber psn;
|
||||||
@ -75,6 +86,7 @@ bool psn_matches_current_process(char *psn_arg_to_check)
|
|||||||
play_tree_t *macosx_finder_args(m_config_t *config, int argc, char **argv)
|
play_tree_t *macosx_finder_args(m_config_t *config, int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc==2 && psn_matches_current_process(argv[1])) {
|
if (argc==2 && psn_matches_current_process(argv[1])) {
|
||||||
|
macosx_redirect_output_to_logfile("mplayer2");
|
||||||
m_config_set_option0(config, "quiet", NULL, false);
|
m_config_set_option0(config, "quiet", NULL, false);
|
||||||
macosx_wait_fileopen_events();
|
macosx_wait_fileopen_events();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user