Coverage for src / ezpl / __init__.py: 91.67%

22 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-13 19:35 +0000

1# /////////////////////////////////////////////////////////////// 

2# EZPL - Main Module 

3# Project: ezpl 

4# /////////////////////////////////////////////////////////////// 

5 

6""" 

7Ezpl - Modern Python logging framework. 

8 

9Ezpl is a modern Python library for advanced log management, using **Rich** 

10for console output and **loguru** for file logging, with a simple and typed API, 

11suitable for professional and industrial applications. 

12 

13**Main Features:** 

14 - Singleton pattern for global logging instance 

15 - Rich-based console output with colors and formatting 

16 - Loguru-based file logging with rotation support 

17 - Contextual indentation management 

18 - Pattern-based logging (SUCCESS, ERROR, WARN, TIP, etc.) 

19 - JSON display support 

20 - Robust error handling 

21 

22**Quick Start:** 

23 >>> from ezpl import Ezpl 

24 >>> ezpl = Ezpl() 

25 >>> printer = ezpl.get_printer() 

26 >>> logger = ezpl.get_logger() 

27 >>> printer.info("Hello, Ezpl!") 

28 >>> logger.info("Logged to file") 

29""" 

30 

31from __future__ import annotations 

32 

33# /////////////////////////////////////////////////////////////// 

34# IMPORTS 

35# /////////////////////////////////////////////////////////////// 

36# Standard library imports 

37import sys 

38 

39# Local imports 

40from .config import ConfigurationManager 

41from .core.exceptions import ( 

42 ConfigurationError, 

43 EzplError, 

44 FileOperationError, 

45 HandlerError, 

46 InitializationError, 

47 LoggingError, 

48 ValidationError, 

49) 

50from .ezpl import Ezpl 

51from .handlers import EzLogger, EzPrinter, RichWizard 

52from .types import ( 

53 PATTERN_COLORS, 

54 LoggerProtocol, 

55 LogLevel, 

56 Pattern, 

57 PrinterProtocol, 

58 get_pattern_color, 

59 get_pattern_color_by_name, 

60) 

61from .version import __version__ 

62 

63# /////////////////////////////////////////////////////////////// 

64# META INFORMATIONS 

65# /////////////////////////////////////////////////////////////// 

66 

67__author__ = "Neuraaak" 

68__maintainer__ = "Neuraaak" 

69__description__ = "A module for easier logging" 

70__python_requires__ = ">=3.10" 

71__keywords__ = ["logging", "rich", "loguru", "console", "file"] 

72__url__ = "https://github.com/neuraaak/ezplog" 

73__repository__ = "https://github.com/neuraaak/ezplog" 

74 

75# /////////////////////////////////////////////////////////////// 

76# PYTHON VERSION CHECK 

77# /////////////////////////////////////////////////////////////// 

78 

79if sys.version_info < (3, 10): # noqa: UP036 79 ↛ 80line 79 didn't jump to line 80 because the condition on line 79 was never true

80 raise RuntimeError( 

81 f"ezpl {__version__} requires Python 3.10 or higher. " 

82 f"Current version: {sys.version}" 

83 ) 

84 

85# /////////////////////////////////////////////////////////////// 

86# TYPE ALIASES 

87# /////////////////////////////////////////////////////////////// 

88 

89Printer = EzPrinter 

90"""Type alias for EzPrinter (console printer handler). 

91Use this type when you want to annotate a variable that represents a printer. 

92 

93Example: 

94 >>> from ezpl import Ezpl, Printer 

95 >>> ezpl = Ezpl() 

96 >>> printer: Printer = ezpl.get_printer() 

97 >>> printer.info("Hello!") 

98 >>> printer.success("Done!") 

99 >>> printer.print_json({"key": "value"}) 

100""" 

101 

102Logger = EzLogger 

103"""Type alias for EzLogger (file logger handler). 

104Use this type when you want to annotate a variable that represents a logger. 

105 

106Example: 

107 >>> from ezpl import Ezpl, Logger 

108 >>> ezpl = Ezpl() 

109 >>> logger: Logger = ezpl.get_logger() 

110 >>> logger.info("Logged to file") 

111""" 

112 

113# /////////////////////////////////////////////////////////////// 

114# PUBLIC API 

115# /////////////////////////////////////////////////////////////// 

116 

117__all__ = [ 

118 # Main class exports 

119 "Ezpl", 

120 # Handler class exports 

121 "EzPrinter", 

122 "EzLogger", 

123 "RichWizard", 

124 # Configuration exports 

125 "ConfigurationManager", 

126 # Type aliases exports 

127 "Printer", 

128 "Logger", 

129 # Type & pattern exports 

130 "LogLevel", 

131 "Pattern", 

132 "PATTERN_COLORS", 

133 "get_pattern_color", 

134 "get_pattern_color_by_name", 

135 # Protocol exports 

136 "PrinterProtocol", 

137 "LoggerProtocol", 

138 # Exception exports 

139 "EzplError", 

140 "ConfigurationError", 

141 "LoggingError", 

142 "ValidationError", 

143 "InitializationError", 

144 "FileOperationError", 

145 "HandlerError", 

146 # Metadata exports 

147 "__version__", 

148 "__author__", 

149 "__maintainer__", 

150 "__description__", 

151 "__python_requires__", 

152 "__keywords__", 

153 "__url__", 

154 "__repository__", 

155]