#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#
#    Copyright (C) 2017, <NAME> <<EMAIL>>
#


from bbutil.logging import Logging
from bbutil.logging.types import Message
from easyb.bit import debug_data

_index = {
    0: ["INFORM", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"],
    1: ["INFORM", "SERIAL", "DEBUG1", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"],
    2: ["INFORM", "SERIAL", "DEBUG1", "DEBUG1", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"],
    3: ["INFORM", "SERIAL", "DEBUG1", "DEBUG2", "DEBUG3", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"]
}


class SerialLogging(Logging):

    def __init__(self):
        Logging.__init__(self)

        self.setup(index=_index)
        return

    def serial_write(self, data: bytes):
        content = "> {0:s}".format(debug_data(data))
        _message = Message(tag="SERIAL", level="SERIAL", content=content)
        self.append(_message)
        return

    def serial_read(self, data: bytes):
        content = "< {0:s}".format(debug_data(data))
        _message = Message(tag="SERIAL", level="SERIAL", content=content)
        self.append(_message)
        return

#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#
#    Copyright (C) 2017, <NAME> <<EMAIL>>
#


from bbutil.logging import Logging
from bbutil.logging.types import Message
from easyb.bit import debug_data

_index = {
    0: ["INFORM", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"],
    1: ["INFORM", "SERIAL", "DEBUG1", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"],
    2: ["INFORM", "SERIAL", "DEBUG1", "DEBUG1", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"],
    3: ["INFORM", "SERIAL", "DEBUG1", "DEBUG2", "DEBUG3", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"]
}


class SerialLogging(Logging):

    def __init__(self):
        Logging.__init__(self)

        self.setup(index=_index)
        return

    def serial_write(self, data: bytes):
        content = "> {0:s}".format(debug_data(data))
        _message = Message(tag="SERIAL", level="SERIAL", content=content)
        self.append(_message)
        return

    def serial_read(self, data: bytes):
        content = "< {0:s}".format(debug_data(data))
        _message = Message(tag="SERIAL", level="SERIAL", content=content)
        self.append(_message)
        return

#!/usr/bin/python3 # -*- coding: utf-8 -*- # #    Licensed under the Apache License, Version 2.0 (the "License"); #    you may not use this file except in compliance with the License. #    You may obtain a copy of the License at # #        http://www.apache.org/licenses/LICENSE-2.0 # #    Unless required by applicable law or agreed to in writing, software #    distributed under the License is distributed on an "AS IS" BASIS, #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #    See the License for the specific language governing permissions and #    limitations under the License. # #    Copyright (C) 2017, <NAME> <<EMAIL>> #