bls_model.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
  4. # except in compliance with the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the
  9. # License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  10. # either express or implied. See the License for the specific language governing permissions
  11. # and limitations under the License.
  12. """
  13. This module provides a model class for BLS.
  14. """
  15. class LogRecordModel(dict):
  16. """
  17. This class define log record.
  18. """
  19. def __init__(self, message="", timestamp=0):
  20. """
  21. :param message:
  22. log record.
  23. :type message: string
  24. :param timestamp:
  25. log record timestamp.
  26. :type timestamp: int
  27. """
  28. super(LogRecordModel, self).__init__()
  29. self["message"] = message
  30. self["timestamp"] = timestamp
  31. class TagModel(dict):
  32. """
  33. This class define tag.
  34. """
  35. def __init__(self, k, v=""):
  36. """
  37. :param k:
  38. tag key.
  39. :type k: string
  40. :param v:
  41. tag value.
  42. :type v: string
  43. """
  44. super(TagModel, self).__init__()
  45. self["k"] = k
  46. self["v"] = v