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