automizor 0.4.2__py3-none-any.whl → 0.4.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
automizor/__init__.py CHANGED
@@ -1 +1 @@
1
- version = "0.4.2"
1
+ version = "0.4.4"
automizor/log/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from functools import lru_cache
2
2
 
3
- from ._log import JSON
3
+ from ._log import VALUE
4
4
 
5
5
 
6
6
  @lru_cache
@@ -10,61 +10,61 @@ def _get_log():
10
10
  return Log()
11
11
 
12
12
 
13
- def debug(msg: JSON):
13
+ def debug(msg: VALUE):
14
14
  """
15
15
  Writes a debug log message with a level of "DEBUG".
16
16
 
17
17
  Parameters:
18
- msg (JSON): The log message to write. This can be a string, number, boolean, dictionary,
19
- list, or None.
18
+ msg (VALUE): The log message to write. This can be a boolean, string, integer, float
19
+ or a JSON-serializable dictionary or list.
20
20
  """
21
21
 
22
22
  _get_log().write_log("DEBUG", msg)
23
23
 
24
24
 
25
- def info(msg: JSON):
25
+ def info(msg: VALUE):
26
26
  """
27
27
  Writes an info log message with a level of "INFO".
28
28
 
29
29
  Parameters:
30
- msg (JSON): The log message to write. This can be a string, number, boolean, dictionary,
31
- list, or None.
30
+ msg (VALUE): The log message to write. This can be a boolean, string, integer, float
31
+ or a JSON-serializable dictionary or list.
32
32
  """
33
33
 
34
34
  _get_log().write_log("INFO", msg)
35
35
 
36
36
 
37
- def warning(msg: JSON):
37
+ def warning(msg: VALUE):
38
38
  """
39
39
  Writes a warning log message with a level of "WARNING".
40
40
 
41
41
  Parameters:
42
- msg (JSON): The log message to write. This can be a string, number, boolean, dictionary,
43
- list, or None.
42
+ msg (VALUE): The log message to write. This can be a boolean, string, integer, float
43
+ or a JSON-serializable dictionary or list.
44
44
  """
45
45
 
46
46
  _get_log().write_log("WARNING", msg)
47
47
 
48
48
 
49
- def error(msg: JSON):
49
+ def error(msg: VALUE):
50
50
  """
51
51
  Writes an error log message with a level of "ERROR".
52
52
 
53
53
  Parameters:
54
- msg (JSON): The log message to write. This can be a string, number, boolean, dictionary,
55
- list, or None.
54
+ msg (VALUE): The log message to write. This can be a boolean, string, integer, float
55
+ or a JSON-serializable dictionary or list.
56
56
  """
57
57
 
58
58
  _get_log().write_log("ERROR", msg)
59
59
 
60
60
 
61
- def critical(msg: JSON):
61
+ def critical(msg: VALUE):
62
62
  """
63
63
  Writes a critical log message with a level of "CRITICAL".
64
64
 
65
65
  Parameters:
66
- msg (JSON): The log message to write. This can be a string, number, boolean, dictionary,
67
- list, or None.
66
+ msg (VALUE): The log message to write. This can be a boolean, string, integer, float
67
+ or a JSON-serializable dictionary or list.
68
68
  """
69
69
 
70
70
  _get_log().write_log("CRITICAL", msg)
automizor/log/_log.py CHANGED
@@ -12,6 +12,7 @@ LOG_LEVELS = {
12
12
  }
13
13
 
14
14
  JSON = Union[str, int, float, bool, None, Dict[str, "JSON"], List["JSON"]]
15
+ VALUE = Union[str, int, float, bool, JSON]
15
16
 
16
17
 
17
18
  class Log:
@@ -34,7 +35,7 @@ class Log:
34
35
  log.set_level("INFO")
35
36
 
36
37
  # Write a log message
37
- log.info({"key": "value"})
38
+ log.info("This is an info message")
38
39
  """
39
40
 
40
41
  def __init__(self):
@@ -57,15 +58,15 @@ class Log:
57
58
 
58
59
  self.level = level
59
60
 
60
- def write_log(self, level: str, msg: JSON):
61
+ def write_log(self, level: str, msg: VALUE):
61
62
  """
62
63
  Write a log message with the specified log level.
63
64
 
64
65
  Parameters:
65
66
  level (str): The log level of the message. Valid log levels are "DEBUG", "INFO",
66
67
  "WARNING", "ERROR", and "CRITICAL".
67
- msg (JSON): The log message to write. This can be a string, number, boolean, dictionary,
68
- list, or None.
68
+ msg (VALUE): The log message to write. This can be a boolean, string, integer, float
69
+ or a JSON-serializable dictionary or list.
69
70
 
70
71
  Raises:
71
72
  ValueError: If an invalid log level is provided.
@@ -86,6 +87,9 @@ class Log:
86
87
  except json.JSONDecodeError:
87
88
  pass
88
89
 
90
+ if isinstance(msg, (dict, list)):
91
+ msg = json.dumps(msg, ensure_ascii=False)
92
+
89
93
  timestamp = datetime.now(timezone.utc).isoformat()
90
94
  data.append({"level": level, "msg": msg, "timestamp": timestamp})
91
95
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: automizor
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Python Automizor framework
5
5
  Home-page: https://github.com/automizor/automizor-python
6
6
  Author: Christian Fischer
@@ -1,17 +1,17 @@
1
- automizor/__init__.py,sha256=OHlqRD04Kvw_CFYmiIVx7UuOJRTQKtAx1Bl4rkUYHJE,18
1
+ automizor/__init__.py,sha256=Qk6wsgzl7cSMWWZ902odoQ-wBV5Fda2ShX82NN7uHzM,18
2
2
  automizor/exceptions.py,sha256=P5imySIOtG3ZIk2kh41Yod4RnlgTj7Vf0P3M-RuxQJs,1382
3
3
  automizor/job/__init__.py,sha256=DNRuT6cyPQBaPRG4vNalCmEvcJQl-73b5ZDFOfNOwIg,1019
4
4
  automizor/job/_job.py,sha256=_-ehqPwJdY89mWm3_VAuh7KRJdv-8iUu6iMAzwGLHM0,5235
5
- automizor/log/__init__.py,sha256=SVCIoKAQfXMIb99_204dgSqFSHO9T74RXpTZq33akKc,1978
6
- automizor/log/_log.py,sha256=ByMGrQGvcEXs3vV6HpO__3VXnwig6JNecwkEzLlD9zw,2774
5
+ automizor/log/__init__.py,sha256=gEr2SuwN1FgX1NMnbphjg8_gfSic9L15H3WC868A-TQ,2104
6
+ automizor/log/_log.py,sha256=P9jAFXVANs5bAGH6-S0pzuSbRKEcX8VlQ_3uu690awE,2948
7
7
  automizor/storage/__init__.py,sha256=bEY2R0Vk0cqscKYNnX-MM222XrxbLXOvOSBDgFmVPLo,3984
8
8
  automizor/storage/_storage.py,sha256=DXcARkFZ3edoDRrDiR02zkO7LmGkRtcKTHmgPsal0lc,10989
9
9
  automizor/utils/__init__.py,sha256=2trRoR5lljYKbYdxmioSlvzajjQM0Wnoq3bvF9lEZ6w,811
10
10
  automizor/vault/__init__.py,sha256=UjRiW3J0R9ABXc1gXIPyS3cqNCwMWxx0l-C0PsIg7R0,1699
11
11
  automizor/vault/_container.py,sha256=-2y7kASigoIVAebuQBk-0R_sI4gfmvjsMLuMg_tR1xA,1945
12
12
  automizor/vault/_vault.py,sha256=uRsjOjzsstZpYwJoHNg_cpv803Dzo4T2oF6hwiG3Eww,4688
13
- automizor-0.4.2.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
14
- automizor-0.4.2.dist-info/METADATA,sha256=Sg3qP54-DPptnimiQ-bh0mbAlSK12Ve9TeQU-DFS_oA,668
15
- automizor-0.4.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
16
- automizor-0.4.2.dist-info/top_level.txt,sha256=gScDy4I3tP6BMYAsTAlBXrxVh3E00zV0UioxwXJOI3Y,10
17
- automizor-0.4.2.dist-info/RECORD,,
13
+ automizor-0.4.4.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
14
+ automizor-0.4.4.dist-info/METADATA,sha256=ov8bVxRLQVqu-Q5opOucEST3mEOJmQbpblVy1UF3fIA,668
15
+ automizor-0.4.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
16
+ automizor-0.4.4.dist-info/top_level.txt,sha256=gScDy4I3tP6BMYAsTAlBXrxVh3E00zV0UioxwXJOI3Y,10
17
+ automizor-0.4.4.dist-info/RECORD,,