summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2012-03-18 16:06:57 +0100
committerUoti Urpala <uau@mplayer2.org>2012-03-25 22:30:37 +0300
commitae0a38ddf8fe2b0db0dae3c072c322eaaff57dcd (patch)
treec98470c917340436850960126b3be6175b9df32b /osdep
parent19458020a6507c4729706f7bd5f17eb07da3cc51 (diff)
downloadmpv-ae0a38ddf8fe2b0db0dae3c072c322eaaff57dcd.tar.bz2
mpv-ae0a38ddf8fe2b0db0dae3c072c322eaaff57dcd.tar.xz
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.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/macosx_finder_args.m12
1 files changed, 12 insertions, 0 deletions
diff --git a/osdep/macosx_finder_args.m b/osdep/macosx_finder_args.m
index cce5acbcc6..b006f11a79 100644
--- a/osdep/macosx_finder_args.m
+++ b/osdep/macosx_finder_args.m
@@ -24,6 +24,7 @@
static play_tree_t *files = NULL;
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);
@interface FileOpenDelegate : NSObject
@@ -59,6 +60,16 @@ void macosx_wait_fileopen_events()
[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)
{
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)
{
if (argc==2 && psn_matches_current_process(argv[1])) {
+ macosx_redirect_output_to_logfile("mplayer2");
m_config_set_option0(config, "quiet", NULL, false);
macosx_wait_fileopen_events();
}