Skip to content

Instantly share code, notes, and snippets.

@ramuta
Last active August 29, 2015 14:09
Show Gist options
  • Save ramuta/61a613b1ad07b7171806 to your computer and use it in GitHub Desktop.
Save ramuta/61a613b1ad07b7171806 to your computer and use it in GitHub Desktop.
Logga - the most gangsta Android logger :)
package your.package.name;
import android.util.Log;
/*
* Copyright (C) 2014 Matej Ramuta
*
* Logga - the most gangsta Android logger :)
*
* For more info and instructions see a README here: https://github.com/ramuta/logga/blob/master/README.md
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public class Logga {
private static final boolean DEBUGGA = true;
public static void i(final String message) {
if(DEBUGGA) {
final String fullClassName = Thread.currentThread().getStackTrace()[3].getClassName();
final String className = fullClassName.substring(fullClassName.lastIndexOf(".") + 1);
final int lineNumba = Thread.currentThread().getStackTrace()[3].getLineNumber();
Log.i(className, "#" + lineNumba + " " + message);
}
}
public static void e(final String message) {
if(DEBUGGA) {
final String fullClassName = Thread.currentThread().getStackTrace()[3].getClassName();
final String className = fullClassName.substring(fullClassName.lastIndexOf(".") + 1);
final int lineNumba = Thread.currentThread().getStackTrace()[3].getLineNumber();
Log.e(className, "#" + lineNumba + " ERRA!!1 " + message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment