/*
 * Copyright (c) 2015. Ncomz. All Rights Reserved
 */

package com.ntels.kneet.v3.common.util;

import android.util.Log;

import com.ntels.kneet.v3.common.AppConfig;
public class Dlog {

    static final String TAG = "Jino";

    /** Log Level Error **/
    public static final void e(Object message) {

        if ( AppConfig.DEBUG )
            Log.e(TAG, buildLogMsg(message));
    }
    /** Log Level Warning **/
    public static final void w(Object message) {

        if ( AppConfig.DEBUG )
            Log.w(TAG, buildLogMsg(message));
    }
    /** Log Level Information **/
    public static final void i(Object message) {

        if ( AppConfig.DEBUG )
            Log.i(TAG, buildLogMsg(message));
    }
    /** Log Level Debug **/
    public static final void d(Object message) {

        if ( AppConfig.DEBUG )
            Log.d(TAG, buildLogMsg(message));
    }
    /** Log Level Verbose **/
    public static final void v(Object message) {

        if ( AppConfig.DEBUG )
            Log.v(TAG, buildLogMsg(message));
    }

    /** Log Level Error **/
    public static final void e(Object messageTitle, Object message) {

        if ( AppConfig.DEBUG )
            Log.e(TAG, buildLogMsg(messageTitle, message));
    }
    /** Log Level Warning **/
    public static final void w(Object messageTitle, Object message) {

        if ( AppConfig.DEBUG )
            Log.w(TAG, buildLogMsg(messageTitle, message));
    }
    /** Log Level Information **/
    public static final void i(Object messageTitle, Object message) {

        if ( AppConfig.DEBUG )
            Log.i(TAG, buildLogMsg(messageTitle, message));
    }
    /** Log Level Debug **/
    public static final void d(Object messageTitle, Object message) {

        if ( AppConfig.DEBUG )
            Log.d(TAG, buildLogMsg(messageTitle, message));
    }
    /** Log Level Verbose **/
    public static final void v(Object messageTitle, Object message) {

        if ( AppConfig.DEBUG )
            Log.v(TAG, buildLogMsg(messageTitle, message));
    }

    public static String buildLogMsg(Object message) {

        StackTraceElement ste = Thread.currentThread().getStackTrace()[4];

        StringBuilder sb = new StringBuilder();

        sb.append("[");
        sb.append(ste.getFileName().replace(".java", ""));
        sb.append("::");
        sb.append(ste.getMethodName());
        sb.append("]");
        sb.append(message);

        return sb.toString();
    }

    public static String buildLogMsg(Object messageTitle, Object message) {

        StackTraceElement ste = Thread.currentThread().getStackTrace()[4];

        StringBuilder sb = new StringBuilder();

        sb.append("[");
        sb.append(ste.getFileName().replace(".java", ""));
        sb.append("::");
        sb.append(ste.getMethodName());
        sb.append("]");
        sb.append(messageTitle);
        sb.append("=");
        sb.append(message);

        return sb.toString();
    }
}