On Nov 9, 2020, at 08:10:16, Gabriel Zachmann via Cocoa-dev 
<cocoa-dev@lists.apple.com> wrote:
> 
> In more details, my app (written in Swift) logs info using NSLog, like so:
> 
>   NSLog( "App group container: %@", container_group_url_!.path )
> 
> I asked the user to extract the log message using this command in the 
> Terminal:
> 
>   log show --start "2020-07-06 08:20:00" --predicate 'process == "Name of 
> App"' --info --debug

And you're 100% sure the user is doing the right thing, both in your app and 
with the log command? Why not have them simply look in Console and filter on 
your app?

At any rate, it's good to plan ahead and use a different logging mechanism, one 
without all the complications and unknowns of the system log. Like #define your 
own logging command, which can then be routed to any number of different 
systems, even turned on/off by the user if you plan right.

#define log_to_normal 0

#if log_to_normal
        #define LOG(x, ...) NSLog(x, ##__VA_ARGS__)
#else
Illustrating 2 different approaches that produce the same result in the end:
        #define LOG(x, ...) Logger(x, ##__VA_ARGS__)
or
        #define LOG(args...) Logger(__FILE__, __LINE__, __PRETTY_FUNCTION__, 
args)
#endif

Where Logger is your own function or class that simply append-writes to a text 
file in ~/Library/Application Support/<your app>/log.txt or whatever. The 
Logger can have an on/off switch that is toggled by a secret menu item so 
normally it doesn't not log, but when you need the user to turn it on, you can 
instruct them how to show the secret menu item or whatever.

--
Steve Mills
Drummer, Mac geek

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to