diff --git a/.gitignore b/.gitignore
index 00069dd..7ffd778 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
.idea
dist
-logger_rewrite.egg-info
\ No newline at end of file
+logult.egg-info
\ No newline at end of file
diff --git a/README.md b/README.md
index c2ce939..bf8c188 100644
--- a/README.md
+++ b/README.md
@@ -2,13 +2,12 @@
Easy way to log everything
### Install
```bash
-pip install logger_rewrite
+pip install logult
```
### Use
-
-
-
-
+```
+from logult import setup_log
+logger= setup_log(save_dir='saved', name_exp='info.log')
+logger.info('Hello')
+```
diff --git a/assets/hello.png b/assets/hello.png
deleted file mode 100644
index 57b1e7f..0000000
Binary files a/assets/hello.png and /dev/null differ
diff --git a/logger_rewrite/__init__.py b/logger_rewrite/__init__.py
deleted file mode 100644
index c3a814b..0000000
--- a/logger_rewrite/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-import logging
-from pathlib import Path
-from logger_rewrite.logger import setup_logging
-
-
-def setup_log(save_dir='./', name_exp='train'):
- save_dir = Path(save_dir)
- save_dir.mkdir(parents=True, exist_ok=True)
- setup_logging(save_dir)
- logger = get_logger(name_exp)
- return logger
-
-
-def get_logger(name):
- logger = logging.getLogger(name=name)
- logger.setLevel(logging.DEBUG)
- return logger
diff --git a/logger_rewrite/__pycache__/__init__.cpython-36.pyc b/logger_rewrite/__pycache__/__init__.cpython-36.pyc
deleted file mode 100644
index 6226442..0000000
Binary files a/logger_rewrite/__pycache__/__init__.cpython-36.pyc and /dev/null differ
diff --git a/logger_rewrite/__pycache__/logger.cpython-36.pyc b/logger_rewrite/__pycache__/logger.cpython-36.pyc
deleted file mode 100644
index 05748ec..0000000
Binary files a/logger_rewrite/__pycache__/logger.cpython-36.pyc and /dev/null differ
diff --git a/logger_rewrite/__pycache__/utils.cpython-36.pyc b/logger_rewrite/__pycache__/utils.cpython-36.pyc
deleted file mode 100644
index ad57bfe..0000000
Binary files a/logger_rewrite/__pycache__/utils.cpython-36.pyc and /dev/null differ
diff --git a/logult/__init__.py b/logult/__init__.py
new file mode 100644
index 0000000..e09e20e
--- /dev/null
+++ b/logult/__init__.py
@@ -0,0 +1,17 @@
+import logging
+from pathlib import Path
+from logult.logger import setup_logging
+
+
+def setup_log(save_dir='./', name_exp='info.log'):
+ save_dir = Path(save_dir)
+ save_dir.mkdir(parents=True, exist_ok=True)
+ setup_logging(save_dir, exp_name=name_exp)
+ logger = get_logger()
+ return logger
+
+
+def get_logger():
+ logger = logging.getLogger()
+ logger.setLevel(logging.DEBUG)
+ return logger
diff --git a/logult/__pycache__/__init__.cpython-36.pyc b/logult/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000..028de76
Binary files /dev/null and b/logult/__pycache__/__init__.cpython-36.pyc differ
diff --git a/logger_rewrite/__pycache__/__init__.cpython-37.pyc b/logult/__pycache__/__init__.cpython-37.pyc
similarity index 100%
rename from logger_rewrite/__pycache__/__init__.cpython-37.pyc
rename to logult/__pycache__/__init__.cpython-37.pyc
diff --git a/logult/__pycache__/logger.cpython-36.pyc b/logult/__pycache__/logger.cpython-36.pyc
new file mode 100644
index 0000000..00acc75
Binary files /dev/null and b/logult/__pycache__/logger.cpython-36.pyc differ
diff --git a/logger_rewrite/__pycache__/logger.cpython-37.pyc b/logult/__pycache__/logger.cpython-37.pyc
similarity index 100%
rename from logger_rewrite/__pycache__/logger.cpython-37.pyc
rename to logult/__pycache__/logger.cpython-37.pyc
diff --git a/logult/__pycache__/utils.cpython-36.pyc b/logult/__pycache__/utils.cpython-36.pyc
new file mode 100644
index 0000000..ddfaa0a
Binary files /dev/null and b/logult/__pycache__/utils.cpython-36.pyc differ
diff --git a/logger_rewrite/logger.py b/logult/logger.py
similarity index 57%
rename from logger_rewrite/logger.py
rename to logult/logger.py
index f639067..8d9c03c 100644
--- a/logger_rewrite/logger.py
+++ b/logult/logger.py
@@ -1,10 +1,12 @@
import logging
import logging.config
-from logger_rewrite.utils import Cfg
+from logult.utils import Cfg
-def setup_logging(save_dir, default_level=logging.INFO):
+def setup_logging(save_dir, exp_name=None, default_level=logging.INFO):
config = Cfg.load_config_from_name()
+ if exp_name is not None:
+ config['handlers']['info_file_handler']['filename'] = exp_name
for _, handler in config['handlers'].items():
if 'filename' in handler:
handler['filename'] = str(save_dir / handler['filename'])
diff --git a/logger_rewrite/utils.py b/logult/utils.py
similarity index 82%
rename from logger_rewrite/utils.py
rename to logult/utils.py
index a08905b..f45883d 100644
--- a/logger_rewrite/utils.py
+++ b/logult/utils.py
@@ -3,7 +3,7 @@
def download_config(id):
- url = 'https://raw.githubusercontent.com/cuongngm/logger_rewrite/why/config/{}'.format(id)
+ url = 'https://raw.githubusercontent.com/cuongngm/logult/why/config/{}'.format(id)
r = requests.get(url)
config = r.text
return config
diff --git a/saved/info.log b/saved/info.log
index e0e6f68..97a5d60 100644
--- a/saved/info.log
+++ b/saved/info.log
@@ -1,2 +1,3 @@
[2022-06-29 17:55:15,655 - train - INFO] - Hello world
[2022-06-30 10:32:20,378 - train - INFO] - Hello
+[2022-08-22 14:35:42,759 - train - INFO] - abc
diff --git a/setup.py b/setup.py
index 5bdbf77..4c737ac 100644
--- a/setup.py
+++ b/setup.py
@@ -4,14 +4,14 @@
long_description = fh.read()
setuptools.setup(
- name="logger_rewrite",
- version="0.3",
+ name="logult",
+ version="0.1",
author="cuongngm",
author_email="cuonghip0908@gmail.com",
description="log scripts",
long_description=long_description,
long_description_content_type="text/markdown",
- url="https://github.com/cuongngm/logger_rewrite",
+ url="https://github.com/cuongngm/logult",
packages=setuptools.find_packages(),
install_requires=['requests'
],