Android Open Source - android_sdk Log Cat Logger






From Project

Back to project page android_sdk.

License

The source code is released under:

Copyright (c) 2012-2014 adjust GmbH, http://www.adjust.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Softw...

If you think the Android project android_sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

//
//  Logger.java/* w w  w .  ja  v  a  2  s . com*/
//  Adjust
//
//  Created by Christian Wellenbrock on 2013-04-18.
//  Copyright (c) 2013 adjust GmbH. All rights reserved.
//  See the file MIT-LICENSE for copying permission.
//

package com.adjust.sdk;

import static com.adjust.sdk.Constants.LOGTAG;

import java.util.Locale;

import android.util.Log;

public class LogCatLogger implements Logger {

    private LogLevel logLevel;

    public LogCatLogger() {
        setLogLevel(LogLevel.INFO);
    }

    @Override
    public void setLogLevel(LogLevel logLevel) {
        this.logLevel = logLevel;
    }

    @Override
    public void setLogLevelString(String logLevelString) {
        if (null != logLevelString) {
            try {
                setLogLevel(LogLevel.valueOf(logLevelString.toUpperCase(Locale.US)));
            } catch (IllegalArgumentException iae) {
                error("Malformed logLevel '%s', falling back to 'info'", logLevelString);
            }
        }
    }

    @Override
    public void verbose(String message, Object ...parameters) {
        if (logLevel.androidLogLevel <= Log.VERBOSE) {
            Log.v(LOGTAG, String.format(message, parameters));
        }
    }

    @Override
    public void debug(String message, Object ...parameters) {
        if (logLevel.androidLogLevel <= Log.DEBUG) {
            Log.d(LOGTAG, String.format(message, parameters));
        }
    }

    @Override
    public void info(String message, Object ...parameters) {
        if (logLevel.androidLogLevel <= Log.INFO) {
            Log.i(LOGTAG, String.format(message, parameters));
        }
    }

    @Override
    public void warn(String message, Object ...parameters) {
        if (logLevel.androidLogLevel <= Log.WARN) {
            Log.w(LOGTAG, String.format(message, parameters));
        }
    }

    @Override
    public void error(String message, Object ...parameters) {
        if (logLevel.androidLogLevel <= Log.ERROR) {
            Log.e(LOGTAG, String.format(message, parameters));
        }
    }

    @Override
    public void Assert(String message, Object ...parameters) {
        Log.println(Log.ASSERT, LOGTAG, String.format(message, parameters));
    }
}




Java Source Code List

com.adjust.sdk.ActivityHandler.java
com.adjust.sdk.ActivityKind.java
com.adjust.sdk.ActivityPackage.java
com.adjust.sdk.ActivityState.java
com.adjust.sdk.AdjustFactory.java
com.adjust.sdk.Adjust.java
com.adjust.sdk.Constants.java
com.adjust.sdk.IPackageHandler.java
com.adjust.sdk.IRequestHandler.java
com.adjust.sdk.LogCatLogger.java
com.adjust.sdk.Logger.java
com.adjust.sdk.OnFinishedListener.java
com.adjust.sdk.PackageBuilder.java
com.adjust.sdk.PackageHandler.java
com.adjust.sdk.ReferrerReceiver.java
com.adjust.sdk.Reflection.java
com.adjust.sdk.RequestHandler.java
com.adjust.sdk.ResponseData.java
com.adjust.sdk.Util.java
com.adjust.sdk.plugin.AndroidIdUtil.java
com.adjust.sdk.plugin.MacAddressUtil.java
com.adjust.sdk.plugin.MapEntry.java
com.adjust.sdk.plugin.Plugin.java