Skip to content
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.

Feature/log #289

Closed
wants to merge 3 commits into from
Closed

Feature/log #289

wants to merge 3 commits into from

Conversation

VitaminPSG
Copy link

@VitaminPSG VitaminPSG commented Feb 8, 2018

Logs usage:

  • Equivalent of Log.i(javaClass.simpleName, message)
override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.test_activity)
        i("onCreate")
    }
   i {
            when (Build.VERSION.SDK_INT) {
                Build.VERSION_CODES.HONEYCOMB -> "HONEYCOMB"
                Build.VERSION_CODES.FROYO -> "FROYO"
                else -> "UNKNOWN"
            }
       }
i("Custom tag", "Log my version ${Build.VERSION.SDK_INT}")

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot. The email used to register you as an authorized contributor must be the email used for the Git commit.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@googlebot
Copy link

CLAs look good, thanks!

@sourabhv
Copy link

sourabhv commented Feb 8, 2018

I'd prefer it as

info("I have a snake in my boot")
error("To infinity and ... StackOverflowException")
wtf("WTF! I still have a snake in my boot")

And the implementation could be

inline fun Any.info(message: String) = Log.i(javaClass.simpleName, message)

But I don't find this very useful

@romainguy
Copy link
Collaborator

The isLoggable aren't super useful since at that point you've already allocated all your strings.

@lukaspili
Copy link

Many kotlin developer create their own log() function, which calls Timber.d rather than Log.d.
Not sure it's such a great idea to pollute the IDE import window with an identical log() function that you don't want to use.
What about adding a prefix like androidDebug(), androidError(), etc?

@JakeWharton
Copy link
Contributor

I don't think this provides a lot of added value. It's mostly code golfing character count. The lazy string one is interesting to potentially add as static extensions onto Log that check isLoggable, but we can't do that until https://youtrack.jetbrains.com/issue/KT-11968 is fixed so going to close for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants