[android-developers] Re: Stripping Log._ out of production
Would the Application class be a good place for this? The android.app.Application class The android.app.Application is a base class for those who need to maintain global application state. It can be accessed via getApplication() from any Activity or Service. It has a couple of life- cycle methods and will be instantiated by Android automatically if your register it in AndroidManifest.xml. Scott On Oct 12, 6:59 pm, jotobjects jotobje...@gmail.com wrote: Config.DEBUG is always false for the downloaded SDK so now I get it that this the value for the whole platform build (duh). Config.DEBUG is not deprecated contrary to post from Dianne, although other fields in Config are deprecated starting in 1.6. For some reason it seems like you have read the source to find out what is deprecated since it is not shown in the API docs. On Oct 2, 1:16 pm, jotobjects jotobje...@gmail.com wrote: I think you mean that each app should define some internal constant and recompile for release (and not use the Config constants) ? Is that right? Is there a conventional property or mechanism that the Log class uses for isLoggable() method? The 1.6 release notes (API diff) says that all the Config constants EXCEPT DEBUG are deprecated. The 1.6 javadoc does not indicate the deprecation at all - so not clear how a developer would notice the deprecation. On Oct 2, 12:35 pm, fadden fad...@android.com wrote: On Oct 2, 12:14 pm,jotobjectsjotobje...@gmail.com wrote: In 1.6 it is deprecated? What is the correct way to detect debug mode? This is expected to be used as a compile-time constant within the app framework. You can and should build your app for debug or release as you see fit, independent of the state of the platform. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Stripping Log._ out of production
I would imagine it does the string concat and then disregards it. It would concat, pass the final string to the function, fail the if, return, and discard the string... - Dan On Fri, Oct 2, 2009 at 9:31 AM, jsdf jasons...@gmail.com wrote: Hi all, I have been using the following conventions for my applications: - I define a static log(String msg) function centrally as: public static void log(String msg) { if (LOG) Log.v(msg); } - While debugging, LOG is true. For production, LOG is false. - Throughout the code, I will then log with functions like: MainApp.log(This is a logged message, variable a=+a); My question is, if I set LOG to false, will the compiler recognize that the entire log function is useless and not even perform the string concatenation? Or, will it perform the string concatenation, but then immediately disregard the results? Obviously, I prefer the former (fewer ops = better), but I don't know how to check for this. Thanks, jsdf --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Stripping Log._ out of production
Yeah you will still get the concats, which you really don't want to keep (those are really expensive). We typically write logging like this: if (DEBUG) Log.v(foo, this is something: + something); Then when DEBUG is false the entire statement, including string concatenation, is stripped. On Fri, Oct 2, 2009 at 9:17 AM, Dan Sherman impact...@gmail.com wrote: I would imagine it does the string concat and then disregards it. It would concat, pass the final string to the function, fail the if, return, and discard the string... - Dan On Fri, Oct 2, 2009 at 9:31 AM, jsdf jasons...@gmail.com wrote: Hi all, I have been using the following conventions for my applications: - I define a static log(String msg) function centrally as: public static void log(String msg) { if (LOG) Log.v(msg); } - While debugging, LOG is true. For production, LOG is false. - Throughout the code, I will then log with functions like: MainApp.log(This is a logged message, variable a=+a); My question is, if I set LOG to false, will the compiler recognize that the entire log function is useless and not even perform the string concatenation? Or, will it perform the string concatenation, but then immediately disregard the results? Obviously, I prefer the former (fewer ops = better), but I don't know how to check for this. Thanks, jsdf -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Stripping Log._ out of production
android.util.Config.DEBUG is true if this is a debug build. import static android.util.Config.DEBUG; if (DEBUG) ... On Oct 2, 9:48 am, Dianne Hackborn hack...@android.com wrote: Yeah you will still get the concats, which you really don't want to keep (those are really expensive). We typically write logging like this: if (DEBUG) Log.v(foo, this is something: + something); Then when DEBUG is false the entire statement, including string concatenation, is stripped. On Fri, Oct 2, 2009 at 9:17 AM, Dan Sherman impact...@gmail.com wrote: I would imagine it does the string concat and then disregards it. It would concat, pass the final string to the function, fail the if, return, and discard the string... - Dan On Fri, Oct 2, 2009 at 9:31 AM, jsdf jasons...@gmail.com wrote: Hi all, I have been using the following conventions for my applications: - I define a static log(String msg) function centrally as: public static void log(String msg) { if (LOG) Log.v(msg); } - While debugging, LOG is true. For production, LOG is false. - Throughout the code, I will then log with functions like: MainApp.log(This is a logged message, variable a=+a); My question is, if I set LOG to false, will the compiler recognize that the entire log function is useless and not even perform the string concatenation? Or, will it perform the string concatenation, but then immediately disregard the results? Obviously, I prefer the former (fewer ops = better), but I don't know how to check for this. Thanks, jsdf -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Stripping Log._ out of production
android.util.Config.DEBUG is -only- for use by the platform. That probably never have should been in the SDK. (Actually, in either Donut or Eclair these are at least deprecated.) On Fri, Oct 2, 2009 at 11:44 AM, jotobjects jotobje...@gmail.com wrote: android.util.Config.DEBUG is true if this is a debug build. import static android.util.Config.DEBUG; if (DEBUG) ... On Oct 2, 9:48 am, Dianne Hackborn hack...@android.com wrote: Yeah you will still get the concats, which you really don't want to keep (those are really expensive). We typically write logging like this: if (DEBUG) Log.v(foo, this is something: + something); Then when DEBUG is false the entire statement, including string concatenation, is stripped. On Fri, Oct 2, 2009 at 9:17 AM, Dan Sherman impact...@gmail.com wrote: I would imagine it does the string concat and then disregards it. It would concat, pass the final string to the function, fail the if, return, and discard the string... - Dan On Fri, Oct 2, 2009 at 9:31 AM, jsdf jasons...@gmail.com wrote: Hi all, I have been using the following conventions for my applications: - I define a static log(String msg) function centrally as: public static void log(String msg) { if (LOG) Log.v(msg); } - While debugging, LOG is true. For production, LOG is false. - Throughout the code, I will then log with functions like: MainApp.log(This is a logged message, variable a=+a); My question is, if I set LOG to false, will the compiler recognize that the entire log function is useless and not even perform the string concatenation? Or, will it perform the string concatenation, but then immediately disregard the results? Obviously, I prefer the former (fewer ops = better), but I don't know how to check for this. Thanks, jsdf -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Stripping Log._ out of production
In 1.6 it is deprecated? What is the correct way to detect debug mode? On Oct 2, 11:59 am, Dianne Hackborn hack...@android.com wrote: android.util.Config.DEBUG is -only- for use by the platform. That probably never have should been in the SDK. (Actually, in either Donut or Eclair these are at least deprecated.) On Fri, Oct 2, 2009 at 11:44 AM, jotobjects jotobje...@gmail.com wrote: android.util.Config.DEBUG is true if this is a debug build. import static android.util.Config.DEBUG; if (DEBUG) ... On Oct 2, 9:48 am, Dianne Hackborn hack...@android.com wrote: Yeah you will still get the concats, which you really don't want to keep (those are really expensive). We typically write logging like this: if (DEBUG) Log.v(foo, this is something: + something); Then when DEBUG is false the entire statement, including string concatenation, is stripped. On Fri, Oct 2, 2009 at 9:17 AM, Dan Sherman impact...@gmail.com wrote: I would imagine it does the string concat and then disregards it. It would concat, pass the final string to the function, fail the if, return, and discard the string... - Dan On Fri, Oct 2, 2009 at 9:31 AM, jsdf jasons...@gmail.com wrote: Hi all, I have been using the following conventions for my applications: - I define a static log(String msg) function centrally as: public static void log(String msg) { if (LOG) Log.v(msg); } - While debugging, LOG is true. For production, LOG is false. - Throughout the code, I will then log with functions like: MainApp.log(This is a logged message, variable a=+a); My question is, if I set LOG to false, will the compiler recognize that the entire log function is useless and not even perform the string concatenation? Or, will it perform the string concatenation, but then immediately disregard the results? Obviously, I prefer the former (fewer ops = better), but I don't know how to check for this. Thanks, jsdf -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Stripping Log._ out of production
On Oct 2, 12:14 pm, jotobjects jotobje...@gmail.com wrote: In 1.6 it is deprecated? What is the correct way to detect debug mode? This is expected to be used as a compile-time constant within the app framework. You can and should build your app for debug or release as you see fit, independent of the state of the platform. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Stripping Log._ out of production
I think you mean that each app should define some internal constant and recompile for release (and not use the Config constants) ? Is that right? Is there a conventional property or mechanism that the Log class uses for isLoggable() method? The 1.6 release notes (API diff) says that all the Config constants EXCEPT DEBUG are deprecated. The 1.6 javadoc does not indicate the deprecation at all - so not clear how a developer would notice the deprecation. On Oct 2, 12:35 pm, fadden fad...@android.com wrote: On Oct 2, 12:14 pm, jotobjects jotobje...@gmail.com wrote: In 1.6 it is deprecated? What is the correct way to detect debug mode? This is expected to be used as a compile-time constant within the app framework. You can and should build your app for debug or release as you see fit, independent of the state of the platform. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---