1#!/usr/bin/env python3 2# 3# Copyright 2019 - The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17import datetime 18 19from acts.controllers.fuchsia_lib.base_lib import BaseLib 20 21 22class FuchsiaLoggingLib(BaseLib): 23 24 def __init__(self, addr: str) -> None: 25 super().__init__(addr, "logging") 26 27 def logE(self, message): 28 """Log a message of level Error directly to the syslog. 29 30 Args: 31 message: The message to log. 32 33 Returns: 34 Dictionary, None if success, error if error. 35 """ 36 test_cmd = "logging_facade.LogErr" 37 test_args = { 38 "message": '[%s] %s' % (datetime.datetime.now(), message), 39 } 40 41 return self.send_command(test_cmd, test_args) 42 43 def logI(self, message): 44 """Log a message of level Info directly to the syslog. 45 46 Args: 47 message: The message to log. 48 49 Returns: 50 Dictionary, None if success, error if error. 51 """ 52 test_cmd = "logging_facade.LogInfo" 53 test_args = {"message": '[%s] %s' % (datetime.datetime.now(), message)} 54 55 return self.send_command(test_cmd, test_args) 56 57 def logW(self, message): 58 """Log a message of level Warning directly to the syslog. 59 60 Args: 61 message: The message to log. 62 63 Returns: 64 Dictionary, None if success, error if error. 65 """ 66 test_cmd = "logging_facade.LogWarn" 67 test_args = {"message": '[%s] %s' % (datetime.datetime.now(), message)} 68 69 return self.send_command(test_cmd, test_args) 70