Skip to content

Commit 154cbf9

Browse files
author
Carlos Mão de Ferro
committed
Added logging to pyforms
version 0.1.4.dev0
1 parent 1fe0bb6 commit 154cbf9

3 files changed

Lines changed: 46 additions & 4 deletions

File tree

pyforms/conf.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,49 @@
1+
# !/usr/bin/python3
2+
# -*- coding: utf-8 -*-
3+
4+
""" pyForms
5+
6+
"""
7+
import logging
8+
9+
__author__ = "Ricardo Ribeiro"
10+
__copyright__ = "Copyright 2016 Champalimaud Foundation"
11+
__credits__ = "Ricardo Ribeiro"
12+
__license__ = "MIT"
13+
__maintainer__ = ["Ricardo Ribeiro", "Carlos Mão de Ferro"]
14+
__email__ = ["ricardojvr at gmail.com", "cajomferro at gmail.com"]
15+
__status__ = "Development"
116

217
PYFORMS_MODE = 'GUI'
18+
PYFORMS_LOG_LEVEL = logging.INFO
19+
20+
def setup_pyforms_logger():
21+
""" Setup logger for this app """
22+
# create logger
23+
logger = logging.getLogger('pyforms')
24+
logger.setLevel(PYFORMS_LOG_LEVEL)
25+
26+
# create file handler which logs even debug messages
27+
# fh = logging.FileHandler('{0}.log'.format(APP_NAME))
28+
# fh.setLevel(logging.DEBUG)
29+
# create console handler with a higher log level
30+
ch = logging.StreamHandler()
31+
ch.setLevel(PYFORMS_LOG_LEVEL)
332

33+
# create formatter and add it to the handlers
34+
formatter = logging.Formatter('%(asctime)s | %(levelname)s | %(name)s | %(module)s | %(message)s', datefmt='%d/%m/%Y %I:%M:%S')
35+
# fh.setFormatter(formatter)
36+
ch.setFormatter(formatter)
37+
38+
# add the handlers to the logger
39+
# logger.addHandler(fh)
40+
logger.addHandler(ch)
441

542
try:
643
from settings import *
744
except:
845
pass
46+
47+
setup_pyforms_logger()
48+
49+

pyforms/gui/Controls/ControlPlayer/ControlPlayer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import math
99
import os
10+
import logging
1011
from PyQt4 import uic
1112
from PyQt4 import QtCore, QtGui
1213
from pyforms.gui.Controls.ControlBase import ControlBase
@@ -38,7 +39,8 @@ class ControlPlayer(ControlBase, QtGui.QFrame):
3839
def __init__(self, *args):
3940
QtGui.QFrame.__init__(self)
4041
ControlBase.__init__(self, *args)
41-
42+
43+
self.logger = logging.getLogger('pyforms')
4244

4345
def initForm(self):
4446
# Get the current path of the file
@@ -272,8 +274,7 @@ def value(self, value):
272274
self._value = value
273275

274276
self.fps = self._value.get(5)
275-
print("Open video with", self._value.get( 5), 'fps')
276-
277+
self.logger.debug("Open video with %s fps", '{0}'.format(self._value.get( 5)))
277278

278279
if self._value and value != 0:
279280
self.videoProgress.setMinimum(0)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
setup(
1616

1717
name ='PyForms',
18-
version ='0.1.4',
18+
version ='0.1.4.dev0',
1919
description ="""Pyforms is a Python 2.7 and 3.0 framework to develop GUI application,
2020
which promotes modular software design and code reusability with minimal effort.""",
2121
author ='Ricardo Ribeiro',

0 commit comments

Comments
 (0)