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
7
votes
3 answers

NSLog giving me warnings which are not correctable

I have the following line of code in my Mac OS X application: NSLog(@"number of items: %ld", [urlArray count]); And I get the warning: "Format specifies type 'long' but the argument has type 'NSUInteger' (aka 'unsigned int')" However, if I change…
Jackson
  • 3,555
  • 3
  • 34
  • 50
7
votes
3 answers

Why do valid objects show up as Nil using lldb? (Apple LLVM Compiler 3.1, Xcode 4.3.1)

I'm trying to debug through some funky UIView behavior and I keep running into the case where LLDB is absolutely useless and misleading. Let me show you what I mean: NSLog(@"myView: %@", myView); 2012-04-20 15:24:57.070 myProj[35789:f803] myView:…
AlleyGator
  • 1,266
  • 9
  • 13
6
votes
2 answers

Calling NSLog from C++: "Format string is not a string literal (potentially insecure)"

When I call NSLog from C++, Xcode complains that the format string passed to NSLog is not a literal string. Here's a line of code that triggers the warning: NSLog(CFSTR("Leaking?")); I'm not aware of any way to code a literal NSString in C++, and…
dkh
  • 185
  • 1
  • 2
  • 8
6
votes
2 answers

What format specifier should be used for BOOL?

Possible Duplicate: Objective c formatting string for boolean? What NSLog %-specifier should be used to literally see YES or NO when printing a BOOL?
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
6
votes
3 answers

MonoTouch, NSLog, and TestFlightSdk

I am trying to integrate the TestFlightSdk into an app I've made using MonoTouch. I am trying to implement logging in my app in such a way that it is picked up by the TestFlightSdk. It supposedly picks up NSLogged text automatically, but I can't…
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
6
votes
3 answers

iPhone/iPad : Does having many NSLog() calls affect app preformance or memory?

I would like to know if having many NSLog() calls affects app performance or memory. Does anyone know about such thing? I want to put an NSLog() call in every function in my app (which is a lot) so that I can see crash logs after and trace…
Zigglzworth
  • 6,645
  • 9
  • 68
  • 107
6
votes
1 answer

how to see iphone logging (NSLog) after app restart?

How could I view iphone logging (eg NSLog) after app restart? I'm interested in the answer both for using the (a) simulator and (b) an IOS device. Background - In this case I have some issues no doubt in my code with how the application is supposed…
Greg
  • 34,042
  • 79
  • 253
  • 454
6
votes
0 answers

ObjC NSLog not printing in Xcode console when UITesting iOS11

So have UITesting target that launches an app written in mixed ObjC and Swift code. When running the app target normally, Swift's print() and ObjC's NSLog() statements print to the Xcode console fine on all devices and simulators. But when running…
Alexandre G
  • 1,655
  • 20
  • 30
6
votes
3 answers

Is there a cost to using NSLog liberally?

As a newer programmer, I've discovered the magic of NSlog, and use it all through my code. It's been extremely helpful (along with NSZombieEnabled) in debugging. I can see a definite performance hit on the simulator as it prints out all this stuff.…
Steve
  • 6,332
  • 11
  • 41
  • 53
6
votes
1 answer

NSLog output messages are repeated twice (duplicate) in the console

WE had our existing project code base restructured, wherein a Static Library was separated out to be its own repository and it was added to the project as a submodule. However, one of the issue we're facing is, duplicate print entries of log…
Code.Decode
  • 3,736
  • 4
  • 25
  • 32
6
votes
2 answers

NSLog, NSError, bad access

I was doing a rather ordinary addPersistentStore to an NSPersistentStoreCoordinator, and it generated an &error code. So I went to NSLog it, and got an access error when I did this: NSLog(@"Unresolved error %@, %@", error, [error…
johnrubythecat
  • 1,003
  • 1
  • 13
  • 31
6
votes
2 answers

New line character showing up in NSLog output

I have the following method: - (NSString *)description { return [NSString stringWithFormat:@"Attribute %@: %@", name, [values description]]; } Name is a string, values is an NSArray. I have an NSArray containing several of these objects. When I…
jstm88
  • 3,335
  • 4
  • 38
  • 55
6
votes
3 answers

How to print unsigned char* in NSLog()

Title pretty much says everything. would like to print (NOT in decimal), but in unsigned char value (HEX). example unsigned char data[6] = {70,AF,80,1A, 01,7E}; NSLog(@"?",data); //need this output : 70 AF 80 1A 01 7E Any idea? Thanks in advance.
HelmiB
  • 12,303
  • 5
  • 41
  • 68
6
votes
1 answer

OutputDebugString() with Delphi for MacOS

Is there an NSLog declaration in the Delphi OSX units. I failed to find a substitude for OutputDebugString in a Firemonkey application. The final solution looks like this: /// /// Output debug string. Output debug string can be seen in…
Gad D Lord
  • 6,620
  • 12
  • 60
  • 106
6
votes
2 answers

CocoaLumberjack and NSLog in other libraries

I'm using CocoaLumberjack for all the logging in my app. Using this I can log straight to a file by using DDLogVerbose(...) or any of the available variants. I'm also using fmdb (SQLite wrapper). The problem is that this library uses NSLog() and…
Julian
  • 8,808
  • 8
  • 51
  • 90