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 def __init__(self, addr, tc, client_id): 24 self.address = addr 25 self.test_counter = tc 26 self.client_id = client_id 27 28 def logE(self, message): 29 """Log a message of level Error directly to the syslog. 30 31 Args: 32 message: The message to log. 33 34 Returns: 35 Dictionary, None if success, error if error. 36 """ 37 test_cmd = "logging_facade.LogErr" 38 test_args = { 39 "message": '[%s] %s' % (datetime.datetime.now(), message), 40 } 41 test_id = self.build_id(self.test_counter) 42 self.test_counter += 1 43 44 return self.send_command(test_id, test_cmd, test_args) 45 46 def logI(self, message): 47 """Log a message of level Info directly to the syslog. 48 49 Args: 50 message: The message to log. 51 52 Returns: 53 Dictionary, None if success, error if error. 54 """ 55 test_cmd = "logging_facade.LogInfo" 56 test_args = {"message": '[%s] %s' % (datetime.datetime.now(), message)} 57 test_id = self.build_id(self.test_counter) 58 self.test_counter += 1 59 60 return self.send_command(test_id, test_cmd, test_args) 61 62 def logW(self, message): 63 """Log a message of level Warning directly to the syslog. 64 65 Args: 66 message: The message to log. 67 68 Returns: 69 Dictionary, None if success, error if error. 70 """ 71 test_cmd = "logging_facade.LogWarn" 72 test_args = {"message": '[%s] %s' % (datetime.datetime.now(), message)} 73 test_id = self.build_id(self.test_counter) 74 self.test_counter += 1 75 76 return self.send_command(test_id, test_cmd, test_args) 77