Coretex
coretex.logging.severity.LogSeverity Class Reference

Inherits IntEnum.

Public Member Functions

int color (self)
 
int getLevel (self)
 
str prefix (self)
 

Static Public Member Functions

LogSeverity fromLevel (int logLevel)
 

Detailed Description

    List of all log severities supported by Coretex

Definition at line 24 of file severity.py.

Member Function Documentation

◆ color()

int coretex.logging.severity.LogSeverity.color (   self)
    ANSI color of the log severity

    Returns
    -------
    str -> color

Definition at line 37 of file severity.py.

37  def color(self) -> int:
38  """
39  ANSI color of the log severity
40 
41  Returns
42  -------
43  str -> color
44  """
45 
46  if self == LogSeverity.fatal:
47  return 31 # red
48 
49  if self == LogSeverity.error:
50  return 31 # red
51 
52  if self == LogSeverity.warning:
53  return 33 # yellow
54 
55  if self == LogSeverity.info:
56  return 97 # white
57 
58  if self == LogSeverity.debug:
59  return 33 # yellow
60 
61  raise RuntimeError(">> [Coretex] Invalid enum value")
62 

◆ fromLevel()

LogSeverity coretex.logging.severity.LogSeverity.fromLevel ( int  logLevel)
static
    Converts python std module logging level
    into the equivalent log severity from coretex

    Returns
    -------
    LogSeverity -> Coretex log severity

    Example
    -------
    >>> import logging
    \b
    >>> from coretex.logging.log_severity import LogSeverity
    >>> logSeverityValue = LogSeverity.fromStd(logging.INFO)
    >>> print(logSeverityValue)
    LogSeverity.info

Definition at line 110 of file severity.py.

110  def fromLevel(logLevel: int) -> LogSeverity:
111  """
112  Converts python std module logging level
113  into the equivalent log severity from coretex
114 
115  Returns
116  -------
117  LogSeverity -> Coretex log severity
118 
119  Example
120  -------
121  >>> import logging
122  \b
123  >>> from coretex.logging.log_severity import LogSeverity
124  >>> logSeverityValue = LogSeverity.fromStd(logging.INFO)
125  >>> print(logSeverityValue)
126  LogSeverity.info
127  """
128 
129  if logLevel == logging.FATAL:
130  return LogSeverity.fatal
131 
132  if logLevel == logging.ERROR:
133  return LogSeverity.error
134 
135  if logLevel == logging.WARNING:
136  return LogSeverity.warning
137 
138  if logLevel == logging.INFO:
139  return LogSeverity.info
140 
141  if logLevel == logging.DEBUG:
142  return LogSeverity.debug
143 
144  raise ValueError(">> [Coretex] Invalid enum value")

◆ getLevel()

int coretex.logging.severity.LogSeverity.getLevel (   self)
    Converts Coretex log severity into the
    equivalent log level from python std module logging

    Returns
    -------
    int -> python std module logging level

    Example
    -------
    >>> from coretex.logging import LogSeverity
    \b
    >>> print(LogSeverity.info.stdSeverity)
    20

Definition at line 63 of file severity.py.

63  def getLevel(self) -> int:
64  """
65  Converts Coretex log severity into the
66  equivalent log level from python std module logging
67 
68  Returns
69  -------
70  int -> python std module logging level
71 
72  Example
73  -------
74  >>> from coretex.logging import LogSeverity
75  \b
76  >>> print(LogSeverity.info.stdSeverity)
77  20
78  """
79 
80  if self == LogSeverity.fatal:
81  return logging.FATAL
82 
83  if self == LogSeverity.error:
84  return logging.ERROR
85 
86  if self == LogSeverity.warning:
87  return logging.WARNING
88 
89  if self == LogSeverity.info:
90  return logging.INFO
91 
92  if self == LogSeverity.debug:
93  return logging.DEBUG
94 
95  raise RuntimeError(">> [Coretex] Invalid enum value")
96 

◆ prefix()

str coretex.logging.severity.LogSeverity.prefix (   self)
    Prefix of the log severity

    Returns
    -------
    str -> prefix

Definition at line 98 of file severity.py.

98  def prefix(self) -> str:
99  """
100  Prefix of the log severity
101 
102  Returns
103  -------
104  str -> prefix
105  """
106 
107  return self.name.capitalize()
108 

The documentation for this class was generated from the following file: