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
48
votes
4 answers

Any way to print in color with NSLog?

In a typical color terminal, there are escape sequences that one can use to print text in different colors. Typically there are 8 colors available. I tried using the standard, ANSI escape sequences for this in NSLog, but no dice. It does not support…
user945620
44
votes
5 answers

what happens to NSLog info when running on a device?

what happens to NSLog info when running on a device? Where does the text go? Does it get saved? Is it therefore a big overhead when running on a device, or does it effectively get sent to null?
Greg
  • 34,042
  • 79
  • 253
  • 454
41
votes
2 answers

How to print NSMutableURLRequest?

How to print NSMutableURLRequest using NSLog ?
40
votes
3 answers

convert NSData Length from bytes to megs

I am trying to NSLog the number of megs my NSData object is however currently all I can get is bytes by using NSLog(@"%u", myData.length); So how would I change this NSLog statement so I can see something like 2.00 megs any help would be…
HurkNburkS
  • 5,492
  • 19
  • 100
  • 183
39
votes
4 answers

'NSLog' is unavailable: Variadic function is unavailable in swift

I'm new to swift. when I'm learning just basics I got this error at NSLog Here is my code : import UIKit class ViewController: UIViewController { var myString: NSString? override func viewDidLoad() { super.viewDidLoad() …
Himanth
  • 2,381
  • 3
  • 28
  • 41
36
votes
7 answers

Using NSLog for debugging

I have the following code snippet in my Xcode: NSString *digit [[sender titlelabel] text]; NSLog([digit]); I tried to build the application and am getting the following warning message for the line NSLog([digit]); Warning: Format not a string…
Zhen
  • 12,361
  • 38
  • 122
  • 199
36
votes
2 answers

How to print int * & unsigned int* in NSLog?

How to print int* (int pointer) and unsigned int* in log using NSLog? - (int) doSomethingWith:(unsigned int)Msg withWparam:(unsigned int*)wParam withParameter:(int *) lParam { NSLog(@"MSg:%d wParam:%u lParam:%u",Msg,wParam,lParam); //not…
HDdeveloper
  • 4,396
  • 6
  • 40
  • 65
33
votes
6 answers

How to log an long long value with NSLog?

How can I do that? What's the format specifier? For example, I have: long long veryLong = // assume value here NSLog(@"%f", veryLong); // of course wrong...
openfrog
  • 40,201
  • 65
  • 225
  • 373
29
votes
1 answer

Clean NSLog - No timestamp and program name

I almost finishing a clean NSLog with this code: #define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, __VA_ARGS__] UTF8String]); This work fine if I do this: NSLog(@"Show %@ message", @"this"); But, will fail if I user…
Rodrigo
  • 11,909
  • 23
  • 68
  • 101
29
votes
8 answers

How can I see values of Object in NSLog?

Suppose I have an object containing some data. How can I see that data using NSLog? If anyone is not clear about my question, then can ask me again.
Chatar Veer Suthar
  • 15,541
  • 26
  • 90
  • 154
28
votes
2 answers

NSLog() to both console and file

I would like to redirect NSog() to file, but still to see the output in console. I am aware that stderr can be redirected to file using: freopen("file.log", "a+", stderr); but after redirecting it to file, the log is no more shown in the console…
Miroslav Kovac
  • 1,168
  • 1
  • 16
  • 27
28
votes
5 answers

How to print a double with full precision on iOS?

Test case: NSLog(@"%f", M_PI); NSLog(@"%@", [NSString stringWithFormat:@"%f", M_PI]); NSLog(@"%@", [NSNumber numberWithDouble:M_PI]); Results: 3.141593 3.141593 3.141592653589793 Conclusions: 1) Printing via NSLog() or [NSString…
Ariel Malka
  • 15,697
  • 6
  • 31
  • 33
27
votes
3 answers

Print NSString Argument using NSLog

-(void) postToDB:(NSString*) msg{ //print msg NSString *myphp = @"/Applications/MAMP/htdocs/databases/test.php"; NSURL *url = [NSURL URLWithString:myphp]; ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; …
user559142
  • 12,279
  • 49
  • 116
  • 179
27
votes
2 answers

Viewing the console log in iOS7

Prior to iOS7, if I wanted to view the output log of an app running on an iOS device, I would use one of: https://itunes.apple.com/au/app/system-console/id431158981?mt=8 https://itunes.apple.com/au/app/console/id317676250?mt=8 However, since…
tomblah
  • 791
  • 3
  • 9
  • 21
26
votes
2 answers

Why aren’t my Safari App Extension NSLog messages showing up in the console in Xcode?

I’m following Apple’s guide for creating a Safari App Extension. In short, I’ve: Created a new Xcode project (in Xcode 8.1, on macOS 10.12 Sierra) using the Cocoa Application template Created a new target in the app using the Safari Extension…
Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
1
2
3
44 45