Skip to content
Snippets Groups Projects

Restructure log location

Merged Ashwin Kumar Karnad requested to merge restructure-log-location into main
Compare and Show latest version
2 files
+ 53
20
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 25
19
@@ -151,6 +151,28 @@ def read_metadata_from_logfile(logfile: Union[str, Path]) -> dict:
@@ -151,6 +151,28 @@ def read_metadata_from_logfile(logfile: Union[str, Path]) -> dict:
}
}
 
def get_installer_log_file(mpsd_release: str, cmd: str, script_dir: str) -> str:
 
"""Get installer log file name."""
 
# Get machine configs
 
os.environ.get("MPSD_OS", "UNKNOWN_OS")
 
mpsd_microarch = get_native_microarchitecture()
 
# parse logging first
 
# decide the log_file_name
 
installer_log_name, build_log_name = create_log_file_names(
 
mpsd_release=mpsd_release, mpsd_microarch=mpsd_microarch, action=cmd
 
)
 
log_folder = script_dir / mpsd_release / "logs"
 
# if the log_folder dosent exist, dont log this message if
 
# the command is a info-only command
 
if cmd not in ["status", "available"]:
 
if not os.path.exists(log_folder):
 
os.makedirs(log_folder)
 
installer_log_file = log_folder / installer_log_name
 
else:
 
installer_log_file = None
 
return installer_log_file
 
 
def set_up_logging(loglevel="warning", filename=None):
def set_up_logging(loglevel="warning", filename=None):
"""Set up logging.
"""Set up logging.
@@ -885,28 +907,12 @@ def main():
@@ -885,28 +907,12 @@ def main():
# Carry out the action
# Carry out the action
args = parser.parse_args()
args = parser.parse_args()
# Get machine configs
os.environ.get("MPSD_OS", "UNKNOWN_OS")
mpsd_microarch = get_native_microarchitecture()
# target dir is the place where this script exists. the
# target dir is the place where this script exists. the
script_dir = Path(os.path.dirname(os.path.realpath(__file__)))
script_dir = Path(os.path.dirname(os.path.realpath(__file__)))
mpsd_release = args.release
# parse logging first
# decide the log_file_name
installer_log_name, build_log_name = create_log_file_names(
mpsd_release=mpsd_release, mpsd_microarch=mpsd_microarch, action=args.action
)
log_folder = script_dir / mpsd_release / mpsd_microarch / "logs"
# if the log_folder dosent exist, dont log this message if
# the command is a info-only command
if args.action not in ["status", "available"]:
if not os.path.exists(log_folder):
os.makedirs(log_folder)
installer_log_file = log_folder / installer_log_name
else:
installer_log_file = None
set_up_logging(args.loglevel, installer_log_file)
set_up_logging(
 
args.loglevel, get_installer_log_file(args.release, args.action, script_dir)
 
)
# Check the command and run related function
# Check the command and run related function
if args.action == "remove":
if args.action == "remove":
Loading