Re: NSLog displays inconsistent format for NSDate
Re: NSLog displays inconsistent format for NSDate
- Subject: Re: NSLog displays inconsistent format for NSDate
- From: Allan Odgaard via Cocoa-dev <email@hidden>
- Date: Sat, 31 Aug 2019 11:51:02 +0200
On 31 Aug 2019, at 2:49, Carl Hoefs via Cocoa-dev wrote:
Same result if I run it as a system daemon. So as you suggest it seems
there could be some sort of environment sensitivity going on. If only
I knew what env var to set in the shell... UTC really isn't what I'm
looking for.
The issue appears to be that `NSLog` sends your format string and
arguments to the unified logging system, this is what Xcode and Console
displays, and here you get dates formatted using the local time zone.
But it *also* does a simple `stringWithFormat:` and sends the result to
standard error, at least when running in a terminal. This is where you
are seeing a more crude formatting of the date which is not adjusted to
the local time zone.
Open a new tab in your terminal, in that tab run this command:
log stream|grep 'Configured date'
Now run your executable, and in the tab where it is running, you should
see the UTC date, but in the tab where you are watching the log stream,
you get the local date.
_______________________________________________
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