Robot Framework Integrated Development Environment (RIDE)
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 robotide.lib.robot.errors import DataError
17 from robotide.lib.robot.utils import file_writer
18 
19 from .loggerhelper import AbstractLogger
20 
21 
23 
24  def __init__(self, path, level):
25  AbstractLogger.__init__(self, level)
26  self._writer_writer = self._get_writer_get_writer(path) # unit test hook
27 
28  def _get_writer(self, path):
29  try:
30  return file_writer(path)
31  except EnvironmentError as err:
32  raise DataError(err.strerror)
33 
34  def message(self, msg):
35  if self._is_logged_is_logged(msg.level) and not self._writer_writer.closed:
36  entry = '%s | %s | %s\n' % (msg.timestamp, msg.level.ljust(5),
37  msg.message)
38  self._writer_writer.write(entry)
39 
40  def start_suite(self, suite):
41  self.infoinfo("Started test suite '%s'" % suite.name)
42 
43  def end_suite(self, suite):
44  self.infoinfo("Ended test suite '%s'" % suite.name)
45 
46  def start_test(self, test):
47  self.infoinfo("Started test case '%s'" % test.name)
48 
49  def end_test(self, test):
50  self.infoinfo("Ended test case '%s'" % test.name)
51 
52  def start_keyword(self, kw):
53  self.debugdebug(lambda: "Started keyword '%s'" % kw.name)
54 
55  def end_keyword(self, kw):
56  self.debugdebug(lambda: "Ended keyword '%s'" % kw.name)
57 
58  def output_file(self, name, path):
59  self.infoinfo('%s: %s' % (name, path))
60 
61  def close(self):
62  self._writer_writer.close()
Used when variable does not exist.
Definition: errors.py:67
def write(self, message, level, html=False)
Definition: loggerhelper.py:62
def file_writer(path=None, encoding='UTF-8', newline=None)
Definition: robotio.py:21