1 Star 0 Fork 0

robertosassu/ra-verifier

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
log.py 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
robertosassu 提交于 2018-04-12 10:38 . Initial import
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# log.py: display log messages
#
# Copyright (C) 2014 Politecnico di Torino, Italy
# TORSEC group -- http://security.polito.it
#
# Author: Roberto Sassu <roberto.sassu@polito.it>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
import sys
verbose_mode = False
fdlog = None
# TODO: make a class?
def set_verbose_mode(mode):
global verbose_mode
verbose_mode = mode
def log_init(logfile = None):
global fdlog
if fdlog != None:
return
if logfile is None:
fdlog = sys.stdout
else:
try:
fdlog = open(logfile, 'wc')
except:
sys.stdout('Error opening %s' %(logfile))
sys.exit(2)
def log_end():
if fdlog != None and fdlog != sys.stdout:
fdlog.close()
def log_message(message = None):
try:
fdlog.write(message)
fdlog.write('\n')
except:
pass
def log_info(message = None):
if verbose_mode == False:
return
log_message('Info: ' + message)
def log_error(message = None):
log_message('Error: ' + message)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/robertosassu/ra-verifier.git
git@gitee.com:robertosassu/ra-verifier.git
robertosassu
ra-verifier
ra-verifier
master

搜索帮助