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 = { 57 "message": '[%s] %s' % (datetime.datetime.now(), message) 58 } 59 test_id = self.build_id(self.test_counter) 60 self.test_counter += 1 61 62 return self.send_command(test_id, test_cmd, test_args) 63 64 def logW(self, message): 65 """Log a message of level Warning directly to the syslog. 66 67 Args: 68 message: The message to log. 69 70 Returns: 71 Dictionary, None if success, error if error. 72 """ 73 test_cmd = "logging_facade.LogWarn" 74 test_args = { 75 "message": '[%s] %s' % (datetime.datetime.now(), message) 76 } 77 test_id = self.build_id(self.test_counter) 78 self.test_counter += 1 79 80 return self.send_command(test_id, test_cmd, test_args) 81