Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY ginlong-scraper.py ./
COPY logging_config.ini ./

CMD [ "python", "./ginlong-scraper.py" ]
13 changes: 4 additions & 9 deletions ginlong-scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import time
import os
import logging
import logging.config
import schedule

# Not all keys are avilable depending on your setup
Expand Down Expand Up @@ -247,15 +248,9 @@ def main():
global next_run_yes

get_loglevel = os.environ['LOG_LEVEL']
loglevel = logging.INFO
if get_loglevel.lower() == "info":
loglevel = logging.INFO
elif get_loglevel.lower() == "error":
loglevel = logging.ERROR
elif get_loglevel.lower() == "debug":
loglevel = logging.DEBUG

logging.basicConfig(level=loglevel, format='%(asctime)s %(levelname)s %(message)s')
loglevel = get_loglevel.upper()

logging.config.fileConfig('logging_config.ini', defaults={'loglevel': loglevel})
logging.info('Started ginlong-solis-scraper')

schedule.every(5).minutes.at(':00').do(main).run()
Expand Down
21 changes: 21 additions & 0 deletions logging_config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[loggers]
keys=root

[handlers]
keys=stderr

[formatters]
keys=simpleFormatter

[logger_root]
level=DEBUG
handlers=stderr

[handler_stderr]
class=StreamHandler
level=%(loglevel)s
formatter=simpleFormatter
args=(sys.stderr,)

[formatter_simpleFormatter]
format=%(asctime)s %(levelname)s %(message)s