Initial Implementation of Logs
This commit is contained in:
@@ -4,10 +4,15 @@ from crystalpol.shared.config import Config
|
||||
from yaml.loader import SafeLoader
|
||||
import yaml
|
||||
|
||||
from pathlib import Path
|
||||
import setproctitle
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
|
||||
from crystalpol.shared.utils import weekday_date_time
|
||||
from crystalpol.shared.utils.log import Log
|
||||
|
||||
__VERSION = "v0.0.1"
|
||||
os.nice(+19)
|
||||
@@ -47,6 +52,16 @@ def main():
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
log_file = Path("run.log")
|
||||
if log_file.exists():
|
||||
log_file.rename(log_file.with_suffix(".log.backup"))
|
||||
|
||||
logging.basicConfig(
|
||||
filename=args.outfile,
|
||||
format='%(message)s',
|
||||
level=logging.INFO
|
||||
)
|
||||
|
||||
try:
|
||||
with open(args.config) as file:
|
||||
data = yaml.load(file, Loader=SafeLoader)
|
||||
@@ -54,6 +69,8 @@ def main():
|
||||
except IOError:
|
||||
raise RuntimeError('Invalid or Missing Config File.')
|
||||
|
||||
Log.make_header(__VERSION, data.get('crystal_pol'))
|
||||
|
||||
pol = Polarization(args.infile, args.outfile, config)
|
||||
pol.run()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user