source: OpenRLabs-Git/web2py/applications/rlabs/modules/logger.py

main
Last change on this file was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100644
File size: 1.4 KB
Line 
1# -*- coding: utf-8 -*-
2#################################################################################
3# @file    logger.py
4# @brief   Class for create openrlabs logs   
5# @warning None
6# @note Use: None     
7# @license GNU GPLv3+
8# @author  David Fuertes, EUPT, University of Zaragoza.
9# @version 1.1.0 - First version
10# @date    2019-15-11
11#################################################################################
12
13import logging
14from logging.handlers import TimedRotatingFileHandler
15
16# create logger with 'spam_application'
17logger = logging.getLogger('openrlabs')
18logger.setLevel(logging.INFO)
19# create file handler which logs even debug messages
20#fh = logging.FileHandler('logs/openrlabs.log')
21fh = logging.handlers.TimedRotatingFileHandler('logs/openrlabs.log', 'midnight', 1, 7)
22fh.setLevel(logging.INFO)
23# create formatter and add it to the handlers
24formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
25fh.setFormatter(formatter)
26# add the handlers to the logger
27logger.addHandler(fh)
28       
29def log(first_name, last_name, pc_name, pc_ip, action):
30    if action == "remote_desktop":
31        msg_action = " connected to Desktop "
32    if action == "do_reserve":
33        msg_action = " get a reserve for "
34    if action == "reserve_error":
35        msg_action = " error in reserve "
36       
37    msg = first_name + " " + last_name + msg_action + pc_name + " " + pc_ip
38    logger.info(msg)
Note: See TracBrowser for help on using the repository browser.