generated from LuisHenri/base-repo-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
41 lines (29 loc) · 1002 Bytes
/
__main__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import logging
import sys
from tendo import singleton
import rufsc.bot
logger = logging.getLogger(__name__)
def main():
rufsc.bot.run() # UTC
def setup_logger():
"""Setup default logging formatter and level."""
for handler in logging.root.handlers[:]:
logging.root.removeHandler(handler)
formatter = logging.Formatter("%(levelname)s %(asctime)s %(name)s: %(message)s")
s_handler = logging.StreamHandler(sys.stdout)
s_handler.setFormatter(formatter)
params = {"level": logging.DEBUG, "handlers": [s_handler]}
logging.basicConfig(**params)
if __name__ == "__main__":
try:
setup_logger()
me = singleton.SingleInstance()
main()
except KeyboardInterrupt:
logger.info("Caught keyboard interrupt")
except singleton.SingleInstanceException:
logger.info("The program was already running")
except Exception as err:
logger.error(err, exc_info=True)
finally:
logger.info("Exiting...")