Skip to content

Commit

Permalink
Merge pull request #2 from fosslight/develop
Browse files Browse the repository at this point in the history
Add common constant variables.
  • Loading branch information
soimkim authored Apr 23, 2021
2 parents 5aa5dc7 + c9192d8 commit 400504b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# FOSSLight Util

<img src="https://img.shields.io/badge/license-Apache--2.0-orange.svg" alt="FOSSLight Util is released under the Apache-2.0." /> <img src="https://img.shields.io/badge/pypi-v1.0-brightgreen.svg" alt="Current python package version." /> <img src="https://img.shields.io/badge/python-3.6+-blue.svg" />
<img src="https://img.shields.io/pypi/l/fosslight_util" alt="FOSSLight Util is released under the Apache-2.0." /> <img src="https://img.shields.io/pypi/v/fosslight_util" alt="Current python package version." /> <img src="https://img.shields.io/pypi/pyversions/fosslight_util" />

It is a package that supports common utils used by FOSSLight Scanner.

## Features
1. It simplifies the logger setup.
2. It easily outputs csv file and excel file in OSS Report format.
3. It provides a simple function to create a text file.
4. It defines common constant variables.

[or]: http://collab.lge.com/main/x/xDHlFg

Expand Down Expand Up @@ -73,6 +74,16 @@ def test():
success, error_msg = write_txt_file("test_result/txt/test.txt",
"Testing - Writing text in a file.")
```

### 4. Load common constant (tests/_print_log_with_another_logger.py)
```
import fosslight_util.constant as constant
logger = logging.getLogger(constant.LOGGER_NAME)
logger.warning("Get a logger after init_log is called once.")
```

## 👏 How to report issue

Please report any ideas or bugs to improve by creating an issue in [fosslight_util repository][cl]. Then there will be quick bug fixes and upgrades. Ideas to improve are always welcome.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if __name__ == "__main__":
setup(
name='fosslight_util',
version='1.0',
version='1.0.1',
package_dir={"": "src"},
packages=find_packages(where='src'),
description='FOSSLight Util',
Expand Down
3 changes: 2 additions & 1 deletion src/fosslight_util/set_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import logging
import os
from pathlib import Path
from . import constant as constant


def init_log(log_file, create_file=True):

logger = logging.getLogger('fosslight')
logger = logging.getLogger(constant.LOGGER_NAME)
if not logger.hasHandlers():
log_level = logging.WARNING
formatter = logging.Formatter('%(message)s')
Expand Down
12 changes: 2 additions & 10 deletions tests/_print_log_with_another_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
# Copyright (c) 2021 LG Electronics Inc.
# SPDX-License-Identifier: Apache-2.0
import logging
import fosslight_util.constant as constant


def print_log_another_logger():
logger = logging.getLogger('ANOTHER_LOGGER_TEST')

log_level = logging.WARNING
formatter = logging.Formatter('%(message)s')

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

logger.warning("Print log by using anther logger")

0 comments on commit 400504b

Please sign in to comment.