• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Event Logging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Event Logging


  • Subject: Re: Event Logging
  • From: Philip Bridson <email@hidden>
  • Date: Tue, 26 Feb 2008 13:31:05 +0000

Yeah that is what I mean. I was reading in the Documentation though that paths to file system folders should not be hard coded. This may sound a little dumb but is the freopen a C function? I used to write in C++ before Obj-C so I haven't used it before. Is it best to use this method or to use File Manager?

Many thanks.

Phil.

On 26 Feb 2008, at 12:58, Martin wrote:

Le 26 févr. 08 à 11:53, Philip Bridson a écrit :
Is event logging really as easy as just declaring the location of the application log directory and then passing the relevant event string to NSLog which will "know" where to write the event?

I'm not sure what you mean when you say "event logging" but the following code in my application's main.m redirects every NSLog output in "~/Library/Logs/MyApp.log":


#ifndef DEBUG
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSString *logPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Logs/MyApp.log"];
freopen([logPath fileSystemRepresentation], "a", stderr);
[pool release];
#endif


The "#ifndef DEBUG" is there to disable the redirection when I'm in debug mode, so that the logs are actually displayed in XCode's console and not in the file.

-Martin

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Event Logging
      • From: Tommy Nordgren <email@hidden>
    • Re: Event Logging
      • From: Martin <email@hidden>
References: 
 >Event Logging (From: Philip Bridson <email@hidden>)
 >Re: Event Logging (From: Martin <email@hidden>)

  • Prev by Date: Re: Event Logging
  • Next by Date: Re: Converting from Window to View Coordinates
  • Previous by thread: Re: Event Logging
  • Next by thread: Re: Event Logging
  • Index(es):
    • Date
    • Thread