Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print the value of a boolean in Log

Tags:

android

Is it possible for me to print the Boolean value returned from a method in a Log message? I am able to print String values, but I am not sure how to print Boolean values in Log message.

like image 559
Andro Selva Avatar asked Jun 16 '11 09:06

Andro Selva


People also ask

How do you print a boolean value?

The println(boolean) method of PrintStream Class in Java is used to print the specified boolean value on the stream and then break the line. This boolean value is taken as a parameter. Parameters: This method accepts a mandatory parameter booleanValue which is the boolean value to be written on the stream.

How do I print boolean in NSLog?

There is no format specifier to print boolean type using NSLog. One way to print boolean value is to convert it to a string. Another way to print boolean value is to cast it to integer, achieving a binary output (1=yes, 0=no).

Can you print a boolean in Python?

Print Boolean values of different data types in PythonUse the built-in bool() method to print the value of a variable.

How do you print a true or false Boolean?

Use std::boolalpha in cout to Print Boolean Values in C++ If it's set to true , it displays the textual form of Boolean values, i.e. true or false , but when it is set to false , we get bool output as 0 and 1 only.


2 Answers

Yes.

Log.v("", "" + booleanValue);

or

Log.v("", Boolean.toString(booleanValue));
like image 132
Plamen Nikolov Avatar answered Oct 23 '22 01:10

Plamen Nikolov


I would do it like this:

Log.d("SomeTag" , booleanValue?"true":"false");
like image 30
whlk Avatar answered Oct 23 '22 01:10

whlk