Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bjk7119 authored May 13, 2021
2 parents 8a0fb93 + 3dddb73 commit 92e6f75
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 1. Update changelog
# 2. Upload a Python Package using Twine

name: Release fosslight_source
name: Release fosslight_util

on:
release:
Expand Down
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Changelog

## v1.0.5 (13/05/2021)
## Changes
## 🔧 Maintenance

- Add options to change stream and file log level @dd-jy (#6)

---

## v1.0.4 (02/05/2021)
## Changes
- Do not print empty sheets @soimkim (#5)

---

## v1.0.3 (29/04/2021)
## Changes
- Add a class for printing spinner @soimkim (#4)

---

## v1.0.2 (23/04/2021)
## Changes
## 🐛 Hotfixes

- Add a file for constant @soimkim (#3)

---

## v1.0.1 (23/04/2021)
## Changes
## 🔧 Maintenance

- Add common constant variables. @soimkim (#2)

---

## Release version 1.0 (23/04/2021)
## Changes
## 🔧 Maintenance

- Update license in setup.py @soimkim (#1)
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@ Three modules can be called. Please refer to each file for detailed calling meth

### 1. Setup logger (tests/test_log.py)
```
from fosslight_util._set_log import init_log
from fosslight_util.set_log import init_log
# 1st param : log file path
# 2nd param : create file (True/False)
# 3rd param : stream log level
# 4th param : file log level
# =>log level(CRITICAL:50, ERROR:40, WARNING:30, INFO:20, DEBUG:10, NOTSET:0)
def test():
logger = init_log("test_result/log_file1.txt")
logger = init_log("test_result/log_file1.txt", True, 30, 20)
logger.warning("TESTING - Print log")
```


### 2. Write csv and excel files (tests/test_excel.py)
```
Expand Down
32 changes: 17 additions & 15 deletions src/fosslight_util/set_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,30 @@
from . import constant as constant


def init_log(log_file, create_file=True):
def init_log(log_file, create_file=True, stream_log_level=logging.WARN, file_log_level=logging.INFO):

logger = logging.getLogger(constant.LOGGER_NAME)

if not logger.hasHandlers():
log_level = logging.WARNING
formatter = logging.Formatter('%(message)s')

logger.setLevel(logging.DEBUG)
log_dir = os.path.dirname(log_file)
Path(log_dir).mkdir(parents=True, exist_ok=True)

if create_file:
file_hanlder = logging.FileHandler(log_file)
file_hanlder.setLevel(log_level)
file_hanlder.setFormatter(formatter)
file_hanlder.propagate = False
logger.addHandler(file_hanlder)

console = logging.StreamHandler()
console.setLevel(log_level)
console.setFormatter(formatter)
console.propagate = False
logger.addHandler(console)

file_handlder = logging.FileHandler(log_file)
file_handlder.setLevel(file_log_level)
file_formatter = logging.Formatter('[%(levelname)7s] %(message)s')
file_handlder.setFormatter(file_formatter)
file_handlder.propagate = False
logger.addHandler(file_handlder)

console_handler = logging.StreamHandler()
console_handler.setLevel(stream_log_level)
console_formatter = logging.Formatter('%(message)s')
console_handler.setFormatter(console_formatter)
console_handler.propagate = False
logger.addHandler(console_handler)

logger.propagate = False

Expand Down

0 comments on commit 92e6f75

Please sign in to comment.