Questions tagged [nslog]

Logs an error message to the Apple System Log facility.

The message consists of a timestamp and the process ID prefixed to the string you pass in. You compose this string with a format string and one or more arguments to be inserted into the string. The format specification allowed by this function is that which is understood by NSString’s formatting capabilities.

Displaying log messages in the system console while running your application is one of the oldest debugging mechanisms available. Using logging, you can generate a transcript describing the operations being performed by your application that you can review long after your application has finished running. Also, while your application is running, you can observe log messages being generated and written to the console as the events in your app they describe are taking place. As a developer, you are in complete control of the text and information displayed in the console by NSLog. Logging can reveal even the toughest to find problems in an app.

Here is an example of what a call to NSLog looks like:

NSString *message = @"test message";

NSLog( @"Here is a test message: '%@'", message );

Console:

Here is a test message: 'test message'

Reference:

Basic debugging with the NSLog function and the DEBUG preprocessor macro

667 questions
5
votes
2 answers

How to do not write log on release mode in iOS?

In my memory, there's some code that can let the NSLog not work when released. I don't want to remove my NSLog in my code.It helps a lot on debug mode. So I want to find a way that can leave them in my code, and also don't slow down the application…
Steven Jiang
  • 1,006
  • 9
  • 21
4
votes
1 answer

No debug output after waiting for App Launch via Push Notification

I found an answer to my original problem here: Debugging App When Launched by Push Notification I want to be able to debug when the app is launched via push notification. This works great and the app sits and waits till its launched remotely.…
Asheh
  • 1,547
  • 16
  • 25
4
votes
4 answers

Does a GCD dispatch_async wait on NSLog()?

From what I've read about Grand Central Dispatch, GCD does not do preemptive multitasking; it is all a single event loop. I'm having trouble making sense of this output. I have two queues just doing some output (at first I was reading/writing some…
jgoldberg
  • 455
  • 5
  • 11
4
votes
1 answer

XCode / Objective C conditional breakpoint based on caller

Ok, i have a requirement to set a breakpoint that only gets "hit" when a method is (or is not) called by a specific object and/or selector the easiest way i can think of doing that is if there were some compiler macro (like _cmd) that unwinds the…
unsynchronized
  • 4,828
  • 2
  • 31
  • 43
4
votes
2 answers

How to NSLog calling function

Not the function calling the NSLog or Dlog but function that call that function. I created a class +(void) computeTime:(void (^)())block { NSDate * currentTime = [NSDate date]; block(); DLog ("Time Running is: %f", [[NSDate date]…
user4951
  • 32,206
  • 53
  • 172
  • 282
4
votes
2 answers

Nslog timestamp

I want to nslog the device motion timestamp property . The device motion is in the class CMMotionManager.devicemotion.timestamp Any ideas.
Abdul Samad
  • 5,748
  • 17
  • 56
  • 70
4
votes
3 answers

how to display method name and the class name in gdb

Hi all i am working on new app from the beginning.upto now i am using nslog function call to display the output on the gdb.but from the some samples providing me the gdb display with the class and method names.i posted some screenshot for that.can…
ajay
  • 3,245
  • 4
  • 31
  • 59
4
votes
2 answers

Which are free available good logging framework for cocoa environment?

As of now I use NSLog for logging from my OS X application. But NSLog gives me no control over log level, size and number of log files. Other problem I face with NSLog is even though I redirect log statements to a file, I still see entries in System…
Unicorn
  • 2,382
  • 6
  • 29
  • 42
4
votes
2 answers

How to use iOS OSLog with Xamarin?

How can I use the iOS OSLog in Xamarin.iOS? I did succeed in using NSLog as follows, but I see no way of setting the subsystem (to the bundle identifier) with NSLog so that I can use that to filter the logs in Console.app. public class Logger { …
Harindaka
  • 4,658
  • 8
  • 43
  • 62
4
votes
0 answers

NSLog: log file rotation / file limits / size limits

Now I searched a while, but didn't found any information about how NSLog works in regards to log file rotation. Are there any file size limits? How many files will be saved? How far back can the log go? What does iOS do if the device gets low on…
testing
  • 19,681
  • 50
  • 236
  • 417
4
votes
2 answers

Redirect print to a File like redirecting NSLog to a file

I have redirected NSLog to a file using the macros. But I couldn't find a stable way in swift to do that. As of now I am doing a workaround I define the following method so whenever I call print in the file it comes here and I write that to a…
Durai Amuthan.H
  • 31,670
  • 10
  • 160
  • 241
4
votes
2 answers

stringByAddingPercentEscapesUsingEncoding not working with NSStrings with ' 0'

I have been having some problem with the stringByAddingPercentEscapesUsingEncoding: method. Here's what happens: When I try to use the method to convert the NSString: "..City=Cl&PostalCode=Rh6 0Nt" I get this this.. "City=Cl&PostalCode=Rh62t" It…
Susanth
  • 61
  • 1
  • 1
  • 5
4
votes
1 answer

NSLog - How to print object name?

Consider, NSString *myString = @"Welcome"; NSLog(@"%@",myString); will print Welcome in console. Can I print the string like "myString: Welcome"? I mean, can I get the object name("myString") along with object value("Welcome")?
Confused
  • 3,846
  • 7
  • 45
  • 72
4
votes
2 answers

Implicit declaration of function 'DLog' is invalid in C99

I used a macro version of NSLog from here, http://objdev.com/2014/06/debug-logging like this, #ifdef DEBUG #define DLog(...) NSLog(@"%s(%p) %@", __PRETTY_FUNCTION__, self, [NSString stringWithFormat:__VA_ARGS__]) #endif It was working fine, until I…
Hemang
  • 26,840
  • 19
  • 119
  • 186
4
votes
3 answers

Storing and retrieving CGPoints inside NSMutableArray

I've looked through countless questions on here and elsewhere and cannot for the life of me figure out what I'm doing wrong. I'm trying to store an array of CGPoints as NSValues inside of an NSMutableArray named points like so on the iPhone: NSValue…
MattDice
  • 195
  • 3
  • 8