Easiest way to remove all the Log statements in project

Put your problem here if it does not fit any of the other categories.

Easiest way to remove all the Log statements in project

Postby amr.btech » Thu Mar 01, 2012 8:42 am

Dear All

Could anybody provide me the easiest or better way to remove all the Log statements in android project using Eclipse.
A. Muni Reddy
Software Developer - Android
amr.btech
Junior Developer
Junior Developer
 
Posts: 13
Joined: Thu Dec 10, 2009 9:16 pm
Location: Mohali

Top

Re: Easiest way to remove all the Log statements in project

Postby vandzi » Thu Mar 01, 2012 3:57 pm

Use Ctrl+h to find all log statements and then remove them manually. I don't know better way.
vandzi
Junior Developer
Junior Developer
 
Posts: 20
Joined: Fri Jun 11, 2010 11:31 am
Location: Slovakia

Re: Easiest way to remove all the Log statements in project

Postby Phyll » Thu Mar 01, 2012 10:55 pm

Hi amer.btech,

Its a little bit of work but you could always make a simple utility that goes through all the files in the src folder of a project and takes out all the Log statements. Start a new stringbuilder then pull the whole file in as a string (most of them aren't that big). Check to see if it contains "Log." and if it does then start this process.

Index the "Log." part. Substring everything up to that number and everything after into two new strings. Then index the second one for the semicolon ";". Substring everything after that.

Just keep doing that to the second string and appending the first ones to your string builder. When the second string contains no more "Log." strings then you are done. You might want to add some more checks to make sure you're really taking a Log statement out but that should do it.

If the file is too big to pull in as a string then you can bring it in a line at a time and check each line and write it back to a new file. Then change the filenames when it is done.

You could make it more elaborate and have it only take out Log.e's or Log.i's or with certain tags.

I guess I was thinking of Java here but a number of other languages excell at this. Perl and Python come to mind.

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Easiest way to remove all the Log statements in project

Postby amr.btech » Fri Mar 02, 2012 7:08 am

Thank you very much Phyll
I will try to do ...as you told...
A. Muni Reddy
Software Developer - Android
amr.btech
Junior Developer
Junior Developer
 
Posts: 13
Joined: Thu Dec 10, 2009 9:16 pm
Location: Mohali

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 17 guests