bytelog 0.1.0__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.
bytelog/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ from .logger import Logger
2
+
3
+ __all__ = ["Logger"]
bytelog/config.py ADDED
@@ -0,0 +1,47 @@
1
+ from pathlib import Path
2
+ from typing import Any
3
+
4
+ import tomlkit
5
+
6
+ path = (Path.cwd() / "pyproject.toml").resolve()
7
+
8
+
9
+ def set_path(path_value: str):
10
+ global path
11
+ path = (Path(path_value) / "pyproject.toml").resolve()
12
+
13
+
14
+ def create_config():
15
+ with open(path, "r", encoding="utf-8") as file:
16
+ config = tomlkit.load(file)
17
+ if "tool" not in config:
18
+ config["tool"] = tomlkit.table()
19
+ config["tool"]["bytelog"] = {}
20
+
21
+ write_config(config)
22
+
23
+
24
+ def get_full_config():
25
+ with open(path, "r", encoding="utf-8") as file:
26
+ config = tomlkit.load(file)
27
+ return config
28
+
29
+
30
+ def write_config(config: tomlkit.TOMLDocument):
31
+ with open(path, "w", encoding="utf-8") as f:
32
+ tomlkit.dump(config, f)
33
+
34
+
35
+ def get_key(key: str):
36
+ config = get_full_config()
37
+ try:
38
+ return config["tool"]["bytelog"][key]
39
+ except KeyError:
40
+ return None
41
+
42
+
43
+ def set_key(key: str, value: Any):
44
+ config = get_full_config()
45
+ config["tool"]["bytelog"][key] = value
46
+
47
+ write_config(config)
bytelog/formatter.py ADDED
@@ -0,0 +1,8 @@
1
+ from . import records
2
+
3
+
4
+ def format_log(record: records.LogRecord):
5
+ formatted = (
6
+ f"[{record.loglevel}] {record.timestamp.strftime('%H:%M:%S')} {record.message}"
7
+ )
8
+ return formatted
bytelog/logger.py ADDED
@@ -0,0 +1,26 @@
1
+ from . import formatter, records
2
+
3
+
4
+ class Logger:
5
+ def __init__(self, name: str, loglevel: str = "DEBUG"):
6
+ self.name = name
7
+ self.loglevel = loglevel
8
+
9
+ def debug(self, message: str):
10
+ log = records.LogRecord("log", "DEBUG", message)
11
+ self._log(log)
12
+
13
+ def info(self, message: str):
14
+ log = records.LogRecord("log", "INFO", message)
15
+ self._log(log)
16
+
17
+ def warn(self, message: str):
18
+ log = records.LogRecord("log", "WARN", message)
19
+ self._log(log)
20
+
21
+ def error(self, message: str):
22
+ log = records.LogRecord("log", "ERROR", message)
23
+ self._log(log)
24
+
25
+ def _log(self, log: records.LogRecord):
26
+ print(formatter.format_log(log))
bytelog/py.typed ADDED
File without changes
bytelog/records.py ADDED
@@ -0,0 +1,12 @@
1
+ from datetime import datetime
2
+
3
+
4
+ class LogRecord:
5
+ def __init__(self, name: str, loglevel: str, message: str):
6
+ self.name = name
7
+ self.loglevel = loglevel
8
+ self.message = message
9
+ self.timestamp = datetime.now()
10
+
11
+ def get(self) -> list[str | datetime]:
12
+ return [self.name, self.loglevel, self.message, self.timestamp]
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: bytelog
3
+ Version: 0.1.0
4
+ Summary: A lightweight logging library.
5
+ Author: nichtnichtjemand
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Programming Language :: Python :: 3.14
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: System :: Logging
12
+ Requires-Dist: tomlkit>=0.15.3
13
+ Requires-Python: >=3.14
14
+ Project-URL: Homepage, https://github.com/nichtnichtjemand/bytelog
15
+ Project-URL: Issues, https://github.com/nichtnichtjemand/bytelog/issues
16
+ Description-Content-Type: text/markdown
17
+
18
+ # Bytelog
19
+
20
+ ## What it is
21
+ Bytelog is a lightweight logging library. Still work in progress!
@@ -0,0 +1,10 @@
1
+ bytelog/__init__.py,sha256=aA3FG5_d3zT4wK6vQync__dbNw2c3LKMT42EfFaT_EU,49
2
+ bytelog/config.py,sha256=Q2p9k8TV_w-1FDu6P3AEU8lI4IR5K4hUbCRWGaA92IY,1015
3
+ bytelog/formatter.py,sha256=S8W163GfduGJfrmkJ9duyAe3sgZztFysNl3fTEjHOT4,200
4
+ bytelog/logger.py,sha256=DxvEhNljz6Uvacm6-lW0TLcdnNx-03BDwgg09Ggli6k,713
5
+ bytelog/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ bytelog/records.py,sha256=AJBSwW_b5avzQROTmoeZwR9zsTdr4eRovJANOFkA3D0,358
7
+ bytelog-0.1.0.dist-info/licenses/LICENSE,sha256=gXySYpm_KgGhY-J8agIXUOtOXoBhY6wgbR0u1HeKh4g,1082
8
+ bytelog-0.1.0.dist-info/WHEEL,sha256=xTCBFIZIIyRSxyowOv5Wqg_jFU6KsdIffuulBB09Ph8,80
9
+ bytelog-0.1.0.dist-info/METADATA,sha256=rxEPwJPjkGre7YszaCBTtop0eQF39julmdYUwhYmJLY,669
10
+ bytelog-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.13.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,10 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 nichtnichtjemand
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+