llog 1.3.0__py3-none-any.whl → 1.4.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.
llog/__init__.py CHANGED
@@ -3,11 +3,11 @@
3
3
 
4
4
  import os
5
5
  import sys
6
+ import fies
6
7
  import json
7
8
  import inspect
8
9
  from sout import sout
9
10
  from datetime import datetime
10
- from fileinit import fileinit
11
11
 
12
12
  # スタックの情報
13
13
  def get_stack_info(stack_back_offset):
@@ -24,7 +24,7 @@ class LLog:
24
24
  self.additional = additional # 追加記録事項
25
25
  if self.additional is None: self.additional = {}
26
26
  # ログ出力ファイルの作成
27
- fileinit(self.filename, overwrite = False, init_str = "") # ファイル初期化 [fileinit]
27
+ if self.filename not in fies: fies[self.filename] = ""
28
28
  # ログ出力 (level: debug) [llog]
29
29
  def debug(self, log_contents):
30
30
  self.__output_log("DEBUG", log_contents, full_stack_flag = False)
@@ -85,3 +85,9 @@ class LLog:
85
85
  if line == "": break
86
86
  obj = json.loads(line)
87
87
  yield obj
88
+ # レコード数
89
+ def __len__(self):
90
+ cnt = 0
91
+ for _ in self:
92
+ cnt += 1
93
+ return cnt
@@ -0,0 +1,11 @@
1
+
2
+ import sys
3
+ from relpath import add_import_path
4
+ add_import_path("../../")
5
+ # local log (globalスコープを汚さないログツール) [llog]
6
+ from llog import LLog
7
+
8
+ # local log (globalスコープを汚さないログツール) [llog]
9
+ main_logger = LLog(
10
+ filename = "./test_log.log"
11
+ )
@@ -0,0 +1,15 @@
1
+
2
+ import sys
3
+ import time
4
+ from my_log_admin import main_logger
5
+
6
+ def my_func():
7
+ # ログ出力 (level: debug) [llog]
8
+ main_logger.debug({"event": "1+1 calculation started"})
9
+ time.sleep(1)
10
+ result = 1+1
11
+ # ログ出力 (level: debug) [llog]
12
+ main_logger.debug({
13
+ "event": "1+1 calculation finished",
14
+ "result": result
15
+ })
llog/test/test_root.py ADDED
@@ -0,0 +1,18 @@
1
+
2
+ import sys
3
+ from my_log_admin import main_logger
4
+ from some_parts import my_func
5
+
6
+ # ログ出力 (level: info) [llog]
7
+ main_logger.info({"event": "app_boot"})
8
+ my_func()
9
+ # ログ出力 (level: info) [llog]
10
+ main_logger.info({"event": "app_terminated"})
11
+
12
+ # 最新ログのレビュー (標準出力)
13
+ main_logger.tail(n = 3)
14
+
15
+ obj = main_logger.tail(n = 3, show_flag = False)
16
+ print(str(obj)[:100])
17
+
18
+ print("%d records"%len(main_logger))
llog/test.py ADDED
@@ -0,0 +1,11 @@
1
+ # local log (globalスコープを汚さないログツール) [llog]
2
+ # 【動作確認 / 使用例】
3
+
4
+ import sys
5
+ import time
6
+ import ezpip
7
+ llog = ezpip.load_develop("llog", "../", develop_flag = True)
8
+
9
+ test_log = llog.LLog("./test_log.log")
10
+ test_log.debug({"msg": "test1"})
11
+ test_log.debug({"msg": "test2"})
@@ -1,118 +1,119 @@
1
- Metadata-Version: 2.1
2
- Name: llog
3
- Version: 1.3.0
4
- Summary: local log (a logging tool that doesn't pollute the global scope)
5
- Home-page: https://github.co.jp/
6
- Author: bib_inf
7
- Author-email: contact.bibinf@gmail.com
8
- License: CC0 v1.0
9
- Platform: UNKNOWN
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Topic :: Software Development :: Libraries
12
- Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
13
- Description-Content-Type: text/markdown
14
- Requires-Dist: relpath
15
- Requires-Dist: sout
16
- Requires-Dist: fileinit
17
-
18
- ※下の方に日本語の説明があります
19
-
20
- ## English description
21
- This package a logging tool that doesn't pollute the global scope.
22
-
23
- How to use
24
-
25
- ```python
26
- from llog import LLog
27
-
28
- test_log = LLog("./test_log.log")
29
- test_log.debug({"msg": "test1"})
30
- test_log.debug({"msg": "test2"})
31
- test_log.debug({"msg": "test3"})
32
-
33
- ```
34
-
35
- Output result: test_log.log
36
- ```json
37
- {"date": "2020-09-22 03:32:59.614418", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test1"}}
38
- {"date": "2020-09-22 03:32:59.616413", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test2"}}
39
- {"date": "2020-09-22 03:32:59.617411", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test3"}}
40
- ```
41
-
42
- You can check the contents of the log file (the last n entries) as follows:
43
-
44
- ```python
45
- test_log.tail(n = 2)
46
- ```
47
-
48
- Result: standard output (console)
49
- ```
50
- [log #1] {
51
- "date": "2020-09-22 03:32:59.616413",
52
- "level": "DEBUG",
53
- "summary_stack": {
54
- "function": "<module>",
55
- "filename": "test_root.py"
56
- },
57
- "contents": {"msg": "test2"}
58
- }
59
- [log #2] {
60
- "date": "2020-09-22 03:32:59.617411",
61
- "level": "DEBUG",
62
- "summary_stack": {
63
- "function": "<module>",
64
- "filename": "test_root.py"
65
- },
66
- "contents": {"msg": "test3"}
67
- }
68
- ```
69
-
70
- ## 日本語の説明
71
- ログの設定範囲を細かく管理できるログツール (他ツールのログ設定と競合しない)
72
-
73
- 簡単な使い方
74
- ```python
75
- from llog import LLog
76
-
77
- test_log = LLog("./test_log.log")
78
- test_log.debug({"msg": "test1"})
79
- test_log.debug({"msg": "test2"})
80
- test_log.debug({"msg": "test3"})
81
-
82
- ```
83
-
84
- 出力結果: test_log.log
85
- ```json
86
- {"date": "2020-09-22 03:32:59.614418", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test1"}}
87
- {"date": "2020-09-22 03:32:59.616413", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test2"}}
88
- {"date": "2020-09-22 03:32:59.617411", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test3"}}
89
- ```
90
-
91
- ログファイルの内容 (末尾n件) を以下のように確認できます。
92
-
93
- ```python
94
- test_log.tail(n = 2)
95
- ```
96
-
97
- 結果: 標準出力 (コンソール)
98
- ```
99
- [log #1] {
100
- "date": "2020-09-22 03:32:59.616413",
101
- "level": "DEBUG",
102
- "summary_stack": {
103
- "function": "<module>",
104
- "filename": "test_root.py"
105
- },
106
- "contents": {"msg": "test2"}
107
- }
108
- [log #2] {
109
- "date": "2020-09-22 03:32:59.617411",
110
- "level": "DEBUG",
111
- "summary_stack": {
112
- "function": "<module>",
113
- "filename": "test_root.py"
114
- },
115
- "contents": {"msg": "test3"}
116
- }
117
- ```
118
-
1
+ Metadata-Version: 2.1
2
+ Name: llog
3
+ Version: 1.4.0
4
+ Summary: local log (a logging tool that doesn't pollute the global scope)
5
+ Home-page: https://github.co.jp/
6
+ Author: bib_inf
7
+ Author-email: contact.bibinf@gmail.com
8
+ License: CC0 v1.0
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Topic :: Software Development :: Libraries
11
+ Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: relpath
14
+ Requires-Dist: sout
15
+ Requires-Dist: fies (>=1.6.0)
16
+
17
+ ※下の方に日本語の説明があります
18
+
19
+ ## English description
20
+ This package a logging tool that doesn't pollute the global scope.
21
+
22
+ How to use
23
+
24
+ ```python
25
+ from llog import LLog
26
+
27
+ test_log = LLog("./test_log.log")
28
+ test_log.debug({"msg": "test1"})
29
+ test_log.debug({"msg": "test2"})
30
+ test_log.debug({"msg": "test3"})
31
+
32
+ ```
33
+
34
+ Output result: test_log.log
35
+ ```json
36
+ {"date": "2020-09-22 03:32:59.614418", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test1"}}
37
+ {"date": "2020-09-22 03:32:59.616413", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test2"}}
38
+ {"date": "2020-09-22 03:32:59.617411", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test3"}}
39
+ ```
40
+
41
+ You can check the contents of the log file (the last n entries) as follows:
42
+
43
+ ```python
44
+ test_log.tail(n = 2)
45
+ ```
46
+
47
+ Result: standard output (console)
48
+ ```
49
+ [log #1] {
50
+ "date": "2020-09-22 03:32:59.616413",
51
+ "level": "DEBUG",
52
+ "summary_stack": {
53
+ "function": "<module>",
54
+ "filename": "test_root.py"
55
+ },
56
+ "contents": {"msg": "test2"}
57
+ }
58
+ [log #2] {
59
+ "date": "2020-09-22 03:32:59.617411",
60
+ "level": "DEBUG",
61
+ "summary_stack": {
62
+ "function": "<module>",
63
+ "filename": "test_root.py"
64
+ },
65
+ "contents": {"msg": "test3"}
66
+ }
67
+ ```
68
+
69
+ ## 日本語の説明
70
+ ログの設定範囲を細かく管理できるログツール (他ツールのログ設定と競合しない)
71
+
72
+ 簡単な使い方
73
+ ```python
74
+ from llog import LLog
75
+
76
+ test_log = LLog("./test_log.log")
77
+ test_log.debug({"msg": "test1"})
78
+ test_log.debug({"msg": "test2"})
79
+ test_log.debug({"msg": "test3"})
80
+
81
+ ```
82
+
83
+ 出力結果: test_log.log
84
+ ```json
85
+ {"date": "2020-09-22 03:32:59.614418", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test1"}}
86
+ {"date": "2020-09-22 03:32:59.616413", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test2"}}
87
+ {"date": "2020-09-22 03:32:59.617411", "level": "DEBUG", "summary_stack": {"function": "<module>", "filename": "test_root.py"}, "contents": {"msg": "test3"}}
88
+ ```
89
+
90
+ ログファイルの内容 (末尾n件) を以下のように確認できます。
91
+
92
+ ```python
93
+ test_log.tail(n = 2)
94
+ ```
95
+
96
+ 結果: 標準出力 (コンソール)
97
+ ```
98
+ [log #1] {
99
+ "date": "2020-09-22 03:32:59.616413",
100
+ "level": "DEBUG",
101
+ "summary_stack": {
102
+ "function": "<module>",
103
+ "filename": "test_root.py"
104
+ },
105
+ "contents": {"msg": "test2"}
106
+ }
107
+ [log #2] {
108
+ "date": "2020-09-22 03:32:59.617411",
109
+ "level": "DEBUG",
110
+ "summary_stack": {
111
+ "function": "<module>",
112
+ "filename": "test_root.py"
113
+ },
114
+ "contents": {"msg": "test3"}
115
+ }
116
+ ```
117
+
118
+ なお、 show_flag = False オプション引数で標準出力がoffにできます。
119
+ また、どちらの場合であっても、標準出力の他に返値として末尾ログ一覧が返ります。
@@ -0,0 +1,9 @@
1
+ llog/__init__.py,sha256=8IH5top2Se4Upjo8eKhwMQVThxoerEPgslj7Sm_MzmM,3056
2
+ llog/test.py,sha256=hJpfVatERauBUGZbV5EoXrbigPw2KfKMPOJtah4rH-g,319
3
+ llog/test/my_log_admin.py,sha256=bUyT-NXbxPepVYdseCdPtLEKWwbLaIW4LQhQTuKwqzU,299
4
+ llog/test/some_parts.py,sha256=uGk38qayZAp2h3nqs9Ez5mae5qwPdsKjVsqn6rfDToU,337
5
+ llog/test/test_root.py,sha256=Y8APRjZF1FJhaXy1tPy6orMo1ruSEOZpMIJlmZl9ehU,447
6
+ llog-1.4.0.dist-info/METADATA,sha256=Mh9l-xquhnHH80JNGCxsfYkcpKiTVC-vReT5bkJBcyg,3608
7
+ llog-1.4.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
8
+ llog-1.4.0.dist-info/top_level.txt,sha256=uIVS5IjCc_yPpbeV2K9JOiskitpbbaXYpco458TXprQ,15
9
+ llog-1.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
- Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.35.1)
3
- Root-Is-Purelib: true
4
- Tag: py3-none-any
5
-
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.38.4)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ llog
2
+ llog\test
@@ -1,5 +0,0 @@
1
- llog/__init__.py,sha256=Z29_KiQOAcHAnIm0Verom0RX551q04NU9yTm33XpHuo,3015
2
- llog-1.3.0.dist-info/METADATA,sha256=OcwYYRGvKKyIJn-5qfq1Kow_W-TJndgymkjinK6OyYM,3294
3
- llog-1.3.0.dist-info/WHEEL,sha256=D1Wh14kWDxPnrM-5t_6UCB-UuQNrEODtRa3vF4OsvQY,97
4
- llog-1.3.0.dist-info/top_level.txt,sha256=GrxxkzQ8yunPDpxKv_-0tqzqArJ-Ap5uiAdW2DAeuBg,5
5
- llog-1.3.0.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- llog