is it possible to get rid of the timestamp in NSLog()?
I want to keep the NSLog functionality but have more simple outputs.
println() is no option because of the behaviour with threads
-
Not answer to your question, but why do you want to keep NSLog? If you push your app to the store with NSLogs, you will get ERROR logged, and if you want to keep it you are using it for your self and can ignore it.Miknash– Miknash2015-03-05 11:30:29 +00:00Commented Mar 5, 2015 at 11:30
-
I just want to create my logs how I need it. The timestamp is mostly needlessMichael– Michael2015-03-05 12:28:25 +00:00Commented Mar 5, 2015 at 12:28
Add a comment
|
1 Answer
Deploy your own log based on println which uses GCD to ensure that it gets executed on the main thread, e.g.
func log(string: String)
{
dispatch_async(dispatch_get_main_queue()) { println(string) }
}
You can also disable this for release with a compiler flag, e.g. see Disabling NSLog For Production In Swift Project.
2 Comments
Michael
I NSLog simply on the main Thread?! Isn't it also synchronising it?
Sebastian
AFAIK
NSLog only ensures, that the output is written thread-safe to stderr (which is another difference to println). Or what do you mean by synchronising? If it shall block the caller until it is done, then use dispatch_sync.