Robot Framework
filelogger.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 from robot.utils import file_writer
17 
18 from .loggerhelper import AbstractLogger
19 
20 
22 
23  def __init__(self, path, level):
24  super().__init__(level)
25  self._writer_writer = self._get_writer_get_writer(path) # unit test hook
26 
27  def _get_writer(self, path):
28  return file_writer(path, usage='syslog')
29 
30  def message(self, msg):
31  if self._is_logged_is_logged(msg.level) and not self._writer_writer.closed:
32  entry = '%s | %s | %s\n' % (msg.timestamp, msg.level.ljust(5),
33  msg.message)
34  self._writer_writer.write(entry)
35 
36  def start_suite(self, suite):
37  self.infoinfo("Started suite '%s'." % suite.name)
38 
39  def end_suite(self, suite):
40  self.infoinfo("Ended suite '%s'." % suite.name)
41 
42  def start_test(self, test):
43  self.infoinfo("Started test '%s'." % test.name)
44 
45  def end_test(self, test):
46  self.infoinfo("Ended test '%s'." % test.name)
47 
48  def start_keyword(self, kw):
49  self.debugdebug(lambda: "Started keyword '%s'." % kw.name)
50 
51  def end_keyword(self, kw):
52  self.debugdebug(lambda: "Ended keyword '%s'." % kw.name)
53 
54  def output_file(self, name, path):
55  self.infoinfo('%s: %s' % (name, path))
56 
57  def close(self):
58  self._writer_writer.close()
def __init__(self, path, level)
Definition: filelogger.py:23
def output_file(self, name, path)
Definition: filelogger.py:54
def write(self, message, level, html=False)
Definition: loggerhelper.py:70
def file_writer(path=None, encoding='UTF-8', newline=None, usage=None)
Definition: robotio.py:25