• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
16import logging
17
18from acts import tracelogger
19
20
21class TakoTraceLogger(tracelogger.TraceLogger):
22    def __init__(self, *args, **kwargs):
23        super().__init__(*args, **kwargs)
24        self.d = self.debug
25        self.e = self.error
26        self.i = self.info
27        self.t = self.step
28        self.w = self.warning
29
30    def _logger_level(self, level_name):
31        level = logging.getLevelName(level_name)
32        return lambda *args, **kwargs: self._logger.log(level, *args, **kwargs)
33
34    def step(self, msg, *args, **kwargs):
35        """Delegate a step call to the underlying logger."""
36        self._log_with(self._logger_level('STEP'), 1, msg, *args, **kwargs)
37
38    def device(self, msg, *args, **kwargs):
39        """Delegate a device call to the underlying logger."""
40        self._log_with(self._logger_level('DEVICE'), 1, msg, *args, **kwargs)
41
42    def suite(self, msg, *args, **kwargs):
43        """Delegate a device call to the underlying logger."""
44        self._log_with(self._logger_level('SUITE'), 1, msg, *args, **kwargs)
45
46    def case(self, msg, *args, **kwargs):
47        """Delegate a case call to the underlying logger."""
48        self._log_with(self._logger_level('CASE'), 1, msg, *args, **kwargs)
49
50    def flush_log(self):
51        """This function exists for compatibility with Tako's logserial module.
52
53        Note that flushing the log is handled automatically by python's logging
54        module.
55        """
56        pass
57