Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8403341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:19:04+00:00 2026-06-09T22:19:04+00:00

I am about to kick off an android project and currently looking at some

  • 0

I am about to kick off an android project and currently looking at some sample codes from internet.
However sometimes it is hard to tell which classes are handling which which functions.

So I start to populate:

Log.d(LogUtils.DEBUG_TAG + getClass().getName(), new Exception().getStackTrace()[0].getMethodName() + " starts.");

to every function.

I just wonder if there is a quick way to auto populate this statement to every function in project?

Thanks vm,
Joe

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:19:05+00:00Added an answer on June 9, 2026 at 10:19 pm

    I am using this code for logs. It automatically give you information about class and method name from which it was called.

    public static void log(final String msg)
    {
    
        final Throwable t = new Throwable();
        final StackTraceElement[] elements = t.getStackTrace();
    
        final String callerClassName = elements[1].getFileName();
        final String callerMethodName = elements[1].getMethodName();
    
       String TAG = "[" + callerClassName + "]";
    
       Log.d(TAG, "[" + callerMethodName + "] " + msg);
    
    }
    

    Here is example:

    log("Hello World");
    

    Gives you:

    [MainActivity.java] [onCreate] Hello World
    

    Now you see that method was called from MainActivity.java file with onCreate method.

    I just wonder if there is a quick way to auto populate this statement
    to every function in project?

    No you need to add it manually. However you can use boolean variable in my method above to turn logs on/off.

    Full source code could be found here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm about to kick off a new project using NHibernate and ASP.Net MVC and
I am using a BizTalk orchestration to kick off an SSIS package. This package
I'm tring to create an SSIS package to import some dataset files, however given
I use Ajax to kick off a PHP script that can take a few
I'm writing a webapp that basically allows users to kick off shell scripts with
I have a webservice method which takes an Id and then will kick off
I kick off 5 uploads (of varying size) via the BackgroundTransferService. I have the
I have the need to kick off a long-running process in response to a
Usually I hear about code working under things apart from IE but Ive got
Is there any way to kick off OptionParser several times in one Ruby program,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.