test_logger.py 921 Bytes
Newer Older
BO ZHANG's avatar
BO ZHANG committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Identifier:     tests/test_logger.py
Name:           test_logger.py
Description:    test logger
Author:         Bo Zhang
Created:        2023-12-15
Modified-History:
    2023-12-15, Bo Zhang, add TestLogger
"""
import os
import unittest

from csst_common.logger import get_logger


class TestFile(unittest.TestCase):
    def test_file(self):
        logger = get_logger(filename="test_logger.log")
        print(os.getcwd())
        print("Type of logger:", type(logger))
        print("Name of logger:", logger.name)
        logger.debug("Well ..")
        logger.info("Hello ...")
        logger.warning("There ...")
        logger.error("Good morning ...")
        with open("test_logger.log", "r") as f:
            lines = f.readlines()
        self.assertTrue(lines[0].endswith("Hello ..."))
        self.assertTrue(lines[1].endswith("There ..."))
        self.assertTrue(lines[2].endswith("Good morning ..."))