1 /* 2 * Copyright (C) 2017 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17 package com.google.android.mobly.snippet.bundled; 18 19 import android.util.Log; 20 import com.google.android.mobly.snippet.Snippet; 21 import com.google.android.mobly.snippet.rpc.Rpc; 22 23 /** Snippet class exposing Android APIs related to logging. */ 24 public class LogSnippet implements Snippet { 25 private String mTag = "MoblyTestLog"; 26 27 @Rpc(description = "Set the tag to use for logX Rpcs. Default is 'MoblyTestLog'.") logSetTag(String tag)28 public void logSetTag(String tag) { 29 mTag = tag; 30 } 31 32 @Rpc(description = "Log at info level.") logI(String message)33 public void logI(String message) { 34 Log.i(mTag, message); 35 } 36 37 @Rpc(description = "Log at debug level.") logD(String message)38 public void logD(String message) { 39 Log.d(mTag, message); 40 } 41 42 @Rpc(description = "Log at error level.") logE(String message)43 public void logE(String message) { 44 Log.e(mTag, message); 45 } 46 47 @Rpc(description = "Log at warning level.") logW(String message)48 public void logW(String message) { 49 Log.w(mTag, message); 50 } 51 52 @Rpc(description = "Log at verbose level.") logV(String message)53 public void logV(String message) { 54 Log.v(mTag, message); 55 } 56 57 @Rpc(description = "Log at WTF level.") logWtf(String message)58 public void logWtf(String message) { 59 Log.wtf(mTag, message); 60 } 61 62 @Override shutdown()63 public void shutdown() {} 64 } 65