Skip to content

Commit

Permalink
chore: remove old dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Oct 11, 2023
1 parent e4f0773 commit 942c65c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
tmp
logs
cache
downloads

*.env
*.log
*.rdb
*.lock
*.pyc
*.lock
*.session
*.session-journal

Expand Down
15 changes: 6 additions & 9 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,14 @@

# ------------------------------------------------------------------------------

_logs_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "logs")
_logs_file = os.path.join(_logs_dir, "kreacher.log")
if not os.path.exists(_logs_dir):
os.makedirs(_logs_dir)
if os.path.exists(_logs_file) and os.stat(_logs_file).st_size > 0:
with open(_logs_file, "w") as f:
_log_file = os.path.join("/tmp", "kreacher.log")
if os.path.exists(_log_file) and os.stat(_log_file).st_size > 0:
with open(_log_file, "w") as f:
f.truncate(0)
print(f'{colored("[INFO]:", "blue")}: LOG FILE WAS FLUSHED SUCCESSFULLY')
elif not os.path.exists(_logs_file):
elif not os.path.exists(_log_file):
try:
with open(_logs_file, "w") as f:
with open(_log_file, "w") as f:
f.write("")
print(f'{colored("[INFO]:", "blue")} LOG FILE CREATED')
except Exception as e:
Expand All @@ -50,7 +47,7 @@
# ------------------------------------------------------------------------------

logging.basicConfig(
filename=_logs_file,
filename=_log_file,
format="[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s",
level=logging.INFO,
)
Expand Down

0 comments on commit 942c65c

Please sign in to comment.