1#!/usr/bin/env python3
2#
3# Copyright (c) 2021 Intel Corporation
4#
5# SPDX-License-Identifier: Apache-2.0
6
7"""
8Dictionary-based Logging Parser Module
9"""
10
11from .log_parser_v1 import LogParserV1
12from .log_parser_v3 import LogParserV3
13
14
15def get_parser(database):
16    """Get the parser object based on database"""
17    db_ver = int(database.get_version())
18
19    # DB version 1 and 2 correspond to v1 parser
20    if db_ver in [1, 2]:
21        return LogParserV1(database)
22
23    # DB version 3 correspond to v3 parser
24    if db_ver == 3:
25        return LogParserV3(database)
26
27    return None
28