Robot Framework
logger.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 
67 
68 import logging
69 
70 from robot.output import librarylogger
71 from robot.running.context import EXECUTION_CONTEXTS
72 
73 
74 
84 def write(msg, level='INFO', html=False):
85  if EXECUTION_CONTEXTS.current is not None:
86  librarylogger.write(msg, level, html)
87  else:
88  logger = logging.getLogger("RobotFramework")
89  level = {'TRACE': logging.DEBUG // 2,
90  'DEBUG': logging.DEBUG,
91  'INFO': logging.INFO,
92  'HTML': logging.INFO,
93  'WARN': logging.WARN,
94  'ERROR': logging.ERROR}[level]
95  logger.log(level, msg)
96 
97 
98 
99 def trace(msg, html=False):
100  write(msg, 'TRACE', html)
101 
102 
103 
104 def debug(msg, html=False):
105  write(msg, 'DEBUG', html)
106 
107 
108 
113 def info(msg, html=False, also_console=False):
114  write(msg, 'INFO', html)
115  if also_console:
116  console(msg)
117 
118 
119 
120 def warn(msg, html=False):
121  write(msg, 'WARN', html)
122 
123 
124 
126 def error(msg, html=False):
127  write(msg, 'ERROR', html)
128 
129 
130 
139 def console(msg, newline=True, stream='stdout'):
140  librarylogger.console(msg, newline, stream)
def info(msg, html=False, also_console=False)
Writes the message to the log file using the INFO level.
Definition: logger.py:113
def trace(msg, html=False)
Writes the message to the log file using the TRACE level.
Definition: logger.py:99
def console(msg, newline=True, stream='stdout')
Writes the message to the console.
Definition: logger.py:139
def debug(msg, html=False)
Writes the message to the log file using the DEBUG level.
Definition: logger.py:104
def warn(msg, html=False)
Writes the message to the log file using the WARN level.
Definition: logger.py:120
def write(msg, level='INFO', html=False)
Writes the message to the log file using the given level.
Definition: logger.py:84
def error(msg, html=False)
Writes the message to the log file using the ERROR level.
Definition: logger.py:126