Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of IPAACA, the
# "Incremental Processing Architecture
# for Artificial Conversational Agents".
#
# Copyright (c) 2009-2015 Social Cognitive Systems Group
# CITEC, Bielefeld University
#
# http://opensource.cit-ec.de/projects/ipaaca/
# http://purl.org/net/ipaaca
#
# This file may be licensed under the terms of of the
# GNU Lesser General Public License Version 3 (the ``LGPL''),
# or (at your option) any later version.
#
# Software distributed under the License is distributed
# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
# express or implied. See the LGPL for the specific language
# governing rights and limitations.
#
# You should have received a copy of the LGPL along with this
# program. If not, go to http://www.gnu.org/licenses/lgpl.html
# or write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The development of this software was supported by the
# Excellence Cluster EXC 277 Cognitive Interaction Technology.
# The Excellence Cluster EXC 277 is a grant of the Deutsche
# Forschungsgemeinschaft (DFG) in the context of the German
# Excellence Initiative.
from __future__ import division, print_function
import sys
import time
import ipaaca
import ipaaca.util.logger as ipaacalog
def main(log_mode, filename=None):
ipaacalog.logger_send_ipaaca_logs(False)
il = ipaacalog.LoggerComponent(filename, log_mode)
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
il.close_logfile()
print('Logging-Component closed by keyboard interrupt.')
if __name__ == '__main__':
try:
iap = ipaaca.IpaacaArgumentParser(
'ipaaca-logger')
iap.add_argument(
'-m', '--log-mode', dest='log_mode',
choices=ipaacalog.LOG_MODES,
default='append',
help="set what to do when logfile exists "
"(default: 'append'; 'timestamp' adds timestamp in any case)")
iap.add_argument(
'filename', nargs='?',
metavar='FILE',
help='set name of logfile')
arguments = iap.parse_args()
main(arguments.log_mode, arguments.filename)
except KeyboardInterrupt:
pass
except Exception, e:
print(u'Exception: '+unicode(traceback.format_exc()))
ipaaca.exit(1)
ipaaca.exit(0)