Coverage for birdplan/bird_config/sections/log.py: 94%
17 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 03:27 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 03:27 +0000
1#
2# SPDX-License-Identifier: GPL-3.0-or-later
3#
4# Copyright (c) 2019-2024, AllWorldIT
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
19"""BIRD logging configuration."""
21from ..globals import BirdConfigGlobals
22from .base import SectionBase
24__all__ = ["SectionLogging"]
27class SectionLogging(SectionBase):
28 """BIRD logging configuration."""
30 def __init__(self, birdconfig_globals: BirdConfigGlobals):
31 """Initialize the object."""
32 super().__init__(birdconfig_globals)
34 # Set section header
35 self._section = "Logging"
37 def configure(self) -> None:
38 """Configure logging."""
39 super().configure()
41 # Grab logfile if we have one
42 log_file = self.birdconfig_globals.log_file
43 if log_file:
44 self.conf.add(f'log "{log_file}" all;')
45 else:
46 self.conf.add("log stderr all;")
47 # Check if we're in debug mode
48 if self.birdconfig_globals.debug:
49 self.conf.add("debug protocols { states, routes, filters, interfaces, events };")
50 self.conf.add("")