loggingkit 1.0.0__tar.gz
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.
- loggingkit-1.0.0/PKG-INFO +87 -0
- loggingkit-1.0.0/README.md +80 -0
- loggingkit-1.0.0/loggingkit/__init__.py +21 -0
- loggingkit-1.0.0/loggingkit/core.py +30 -0
- loggingkit-1.0.0/loggingkit.egg-info/PKG-INFO +87 -0
- loggingkit-1.0.0/loggingkit.egg-info/SOURCES.txt +8 -0
- loggingkit-1.0.0/loggingkit.egg-info/dependency_links.txt +1 -0
- loggingkit-1.0.0/loggingkit.egg-info/top_level.txt +1 -0
- loggingkit-1.0.0/pyproject.toml +7 -0
- loggingkit-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: loggingkit
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A simple Python logging utility
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# LoggingKit
|
|
9
|
+
|
|
10
|
+
A simple Python logging utility
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install loggerkit
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Importing
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
import loggerkit
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Just as an example, we will use this code:
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
log1 = loggerkit.Log()
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### create\_log()
|
|
33
|
+
|
|
34
|
+
The function log() takes one argument: the name of the log. It creates a new log
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
log1.log("test")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### warning()
|
|
41
|
+
|
|
42
|
+
The function warning() takes two arguments: the name of the log you want the warning in and the warning. It creates the specified warning in the specified log.
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
log1.warning("test", "This is a warning")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### info()
|
|
49
|
+
|
|
50
|
+
The function info() takes two arguments: the name of the log you want the info in and the info. It creates the specified info in the specified log.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
log1.info("test", "This is an info")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### error()
|
|
57
|
+
|
|
58
|
+
The function error() takes two arguments: the name of the log you want the error in and the error. It creates the specified error in the specified log.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
log1.error("test", "This is an error")
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### return_log()
|
|
65
|
+
|
|
66
|
+
The function return_log() takes one argument: the name of the log you want it to return. It returns the contents of the specified log.
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
log1.return_log("test")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### save_log()
|
|
73
|
+
|
|
74
|
+
The function save_log() takes one argument which has a default, log.json: the name of the file you want to export the logs into. (With the extension!) It exports the set of logs into the specified filename.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
log1.save_log() #The default will be used here
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### open_log()
|
|
81
|
+
|
|
82
|
+
The function open_log() takes one argument, which has a default, log.json: The name of the file you want to import the logs from. (Also with the extension!) It imports the logs from the specified filename.
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
log1.open_log() #The default will be used here as well
|
|
86
|
+
```
|
|
87
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# LoggingKit
|
|
2
|
+
|
|
3
|
+
A simple Python logging utility
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install loggerkit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Importing
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
import loggerkit
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
Just as an example, we will use this code:
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
log1 = loggerkit.Log()
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### create\_log()
|
|
26
|
+
|
|
27
|
+
The function log() takes one argument: the name of the log. It creates a new log
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
log1.log("test")
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### warning()
|
|
34
|
+
|
|
35
|
+
The function warning() takes two arguments: the name of the log you want the warning in and the warning. It creates the specified warning in the specified log.
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
log1.warning("test", "This is a warning")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### info()
|
|
42
|
+
|
|
43
|
+
The function info() takes two arguments: the name of the log you want the info in and the info. It creates the specified info in the specified log.
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
log1.info("test", "This is an info")
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### error()
|
|
50
|
+
|
|
51
|
+
The function error() takes two arguments: the name of the log you want the error in and the error. It creates the specified error in the specified log.
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
log1.error("test", "This is an error")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### return_log()
|
|
58
|
+
|
|
59
|
+
The function return_log() takes one argument: the name of the log you want it to return. It returns the contents of the specified log.
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
log1.return_log("test")
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### save_log()
|
|
66
|
+
|
|
67
|
+
The function save_log() takes one argument which has a default, log.json: the name of the file you want to export the logs into. (With the extension!) It exports the set of logs into the specified filename.
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
log1.save_log() #The default will be used here
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### open_log()
|
|
74
|
+
|
|
75
|
+
The function open_log() takes one argument, which has a default, log.json: The name of the file you want to import the logs from. (Also with the extension!) It imports the logs from the specified filename.
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
log1.open_log() #The default will be used here as well
|
|
79
|
+
```
|
|
80
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import json
|
|
3
|
+
class Log:
|
|
4
|
+
def __init__(self):
|
|
5
|
+
self.logs = dict()
|
|
6
|
+
def log(self, name):
|
|
7
|
+
self.logs[name] = []
|
|
8
|
+
def warning(self, log_name, description):
|
|
9
|
+
self.logs[log_name].append(("W", time.strftime("%H:%M:%S"), description))
|
|
10
|
+
def info(self, log_name, description):
|
|
11
|
+
self.logs[log_name].append(("I", time.strftime("%H:%M:%S"), description))
|
|
12
|
+
def error(self, log_name, description):
|
|
13
|
+
self.logs[log_name].append(("E", time.strftime("%H:%M:%S"), description))
|
|
14
|
+
def return_log(self, log_name):
|
|
15
|
+
return self.logs[log_name]
|
|
16
|
+
def save_log(self, filename="log.log"):
|
|
17
|
+
with open(filename, "w") as f:
|
|
18
|
+
json.dump(self.logs, f, indent=2)
|
|
19
|
+
def open_log(self, filename="log.log"):
|
|
20
|
+
with open(filename) as f:
|
|
21
|
+
self.logs = json.load(f)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import json
|
|
3
|
+
class Logger:
|
|
4
|
+
def __init__(self):
|
|
5
|
+
self.logs = dict()
|
|
6
|
+
def _ensure_log(self, log_name):
|
|
7
|
+
if log_name not in self.logs:
|
|
8
|
+
self.logs[log_name] = []
|
|
9
|
+
def create_log(self, name):
|
|
10
|
+
self.logs[name] = []
|
|
11
|
+
def warning(self, log_name, description):
|
|
12
|
+
self._ensure_log(log_name)
|
|
13
|
+
self.logs[log_name].append(("W", time.strftime("%H:%M:%S"), description))
|
|
14
|
+
def info(self, log_name, description):
|
|
15
|
+
self._ensure_log(log_name)
|
|
16
|
+
self.logs[log_name].append(("I", time.strftime("%H:%M:%S"), description))
|
|
17
|
+
def error(self, log_name, description):
|
|
18
|
+
self._ensure_log(log_name)
|
|
19
|
+
self.logs[log_name].append(("E", time.strftime("%H:%M:%S"), description))
|
|
20
|
+
def return_log(self, log_name):
|
|
21
|
+
self._ensure_log(log_name)
|
|
22
|
+
return self.logs[log_name]
|
|
23
|
+
def save_log(self, filename="log.json"):
|
|
24
|
+
with open(filename, "w") as f:
|
|
25
|
+
json.dump(self.logs, f, indent=2)
|
|
26
|
+
def open_log(self, filename="log.json"):
|
|
27
|
+
with open(filename) as f:
|
|
28
|
+
self.logs = json.load(f)
|
|
29
|
+
def __repr__(self):
|
|
30
|
+
return f"<Logger logs: {len(self.logs)}>"
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: loggingkit
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A simple Python logging utility
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# LoggingKit
|
|
9
|
+
|
|
10
|
+
A simple Python logging utility
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install loggerkit
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Importing
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
import loggerkit
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Just as an example, we will use this code:
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
log1 = loggerkit.Log()
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### create\_log()
|
|
33
|
+
|
|
34
|
+
The function log() takes one argument: the name of the log. It creates a new log
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
log1.log("test")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### warning()
|
|
41
|
+
|
|
42
|
+
The function warning() takes two arguments: the name of the log you want the warning in and the warning. It creates the specified warning in the specified log.
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
log1.warning("test", "This is a warning")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### info()
|
|
49
|
+
|
|
50
|
+
The function info() takes two arguments: the name of the log you want the info in and the info. It creates the specified info in the specified log.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
log1.info("test", "This is an info")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### error()
|
|
57
|
+
|
|
58
|
+
The function error() takes two arguments: the name of the log you want the error in and the error. It creates the specified error in the specified log.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
log1.error("test", "This is an error")
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### return_log()
|
|
65
|
+
|
|
66
|
+
The function return_log() takes one argument: the name of the log you want it to return. It returns the contents of the specified log.
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
log1.return_log("test")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### save_log()
|
|
73
|
+
|
|
74
|
+
The function save_log() takes one argument which has a default, log.json: the name of the file you want to export the logs into. (With the extension!) It exports the set of logs into the specified filename.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
log1.save_log() #The default will be used here
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### open_log()
|
|
81
|
+
|
|
82
|
+
The function open_log() takes one argument, which has a default, log.json: The name of the file you want to import the logs from. (Also with the extension!) It imports the logs from the specified filename.
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
log1.open_log() #The default will be used here as well
|
|
86
|
+
```
|
|
87
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
loggingkit
|