add logging
Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
This commit is contained in:
parent
e52aa70377
commit
d480c49415
|
@ -58,3 +58,4 @@ target/
|
|||
|
||||
# subiquity installer images
|
||||
installer/*.img
|
||||
logs/*
|
||||
|
|
|
@ -16,11 +16,12 @@
|
|||
|
||||
import argparse
|
||||
import sys
|
||||
import logging
|
||||
import urwid
|
||||
import urwid.curses_display
|
||||
from subiquity.palette import STYLES, STYLES_MONO
|
||||
from subiquity.controllers.welcome import WelcomeController
|
||||
from subiquity.app import Application
|
||||
from subiquity.log import setup_logger
|
||||
|
||||
|
||||
def parse_options(argv):
|
||||
|
@ -35,6 +36,9 @@ def parse_options(argv):
|
|||
|
||||
def main():
|
||||
opts = parse_options(sys.argv[1:])
|
||||
setup_logger()
|
||||
logger = logging.getLogger('subiquity')
|
||||
|
||||
if opts.run_on_serial:
|
||||
# screen = urwid.curses_display.Screen()
|
||||
screen = urwid.raw_display.Screen()
|
||||
|
|
|
@ -28,7 +28,7 @@ class Application:
|
|||
def __init__(self, screen, opts):
|
||||
self.screen = screen
|
||||
self.opts = opts
|
||||
self.initial_controller = Routes.first()
|
||||
self.welcome_controller = Routes.first()
|
||||
|
||||
# Setup eventloop
|
||||
self.loop = self._build_loop()
|
||||
|
@ -38,7 +38,7 @@ class Application:
|
|||
""" Builds urwid eventloop, passing in itself to the controllers
|
||||
for further display manipulation
|
||||
"""
|
||||
return urwid.MainLoop(self.initial_controller(routes=Routes,
|
||||
return urwid.MainLoop(self.welcome_controller(routes=Routes,
|
||||
application=self).show(),
|
||||
screen=self.screen,
|
||||
unhandled_input=self.unhandled_input)
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
from subiquity.controllers import BaseController, BaseControllerError
|
||||
from subiquity.views.installpath import InstallpathView
|
||||
from subiquity.models.installpath import InstallpathModel
|
||||
import logging
|
||||
|
||||
log = logging.getLogger('subiquity.installpath')
|
||||
|
||||
|
||||
class InstallpathController(BaseController):
|
||||
|
@ -23,6 +26,7 @@ class InstallpathController(BaseController):
|
|||
controller_name = "Installation path controller"
|
||||
|
||||
def show(self, *args, **kwds):
|
||||
log.debug("Loading install path controller")
|
||||
model = InstallpathModel()
|
||||
return InstallpathView(model, self.finish)
|
||||
|
||||
|
|
|
@ -33,6 +33,6 @@ class WelcomeController(BaseController):
|
|||
"more previous controllers to render.")
|
||||
self.selected_language = language
|
||||
# subprocess.check_call("/usr/local/bin/curtin_wrap.sh")
|
||||
self.next_controller()
|
||||
return self.next_controller()
|
||||
|
||||
__controller_class__ = WelcomeController
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# Copyright 2015 Canonical, Ltd.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
import os
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
|
||||
|
||||
def setup_logger(name=__name__):
|
||||
LOGDIR = "logs"
|
||||
LOGFILE = os.path.join(LOGDIR, "debug.log")
|
||||
if not os.path.isdir(LOGDIR):
|
||||
os.makedirs(LOGDIR)
|
||||
log = TimedRotatingFileHandler(LOGFILE,
|
||||
when='D',
|
||||
interval=1,
|
||||
backupCount=7)
|
||||
log.setLevel('DEBUG')
|
||||
log.setFormatter(logging.Formatter(
|
||||
"[%(levelname)-4s: %(asctime)s, "
|
||||
"%(filename)s:%(lineno)d] %(message)s",
|
||||
datefmt='%m-%d %H:%M:%S'))
|
||||
log_filter = logging.Filter(name='subiquity')
|
||||
log.addFilter(log_filter)
|
||||
|
||||
logger = logging.getLogger('')
|
||||
logger.setLevel('DEBUG')
|
||||
logger.addHandler(log)
|
||||
return logger
|
|
@ -51,16 +51,6 @@ class Routes:
|
|||
""" end of install, last controller """
|
||||
return cls.route(-1)
|
||||
|
||||
@classmethod
|
||||
def go_to_beginning(cls):
|
||||
cls.current_route_idx = 0
|
||||
return cls.route(0)
|
||||
|
||||
@classmethod
|
||||
def go_to_end(cls):
|
||||
cls.current_route_idx = len(cls.routes) - 1
|
||||
return cls.route(-1)
|
||||
|
||||
@classmethod
|
||||
def next(cls):
|
||||
cls.current_route_idx = cls.current_route_idx + 1
|
||||
|
|
Loading…
Reference in New Issue