Beispiel #1
0
def py_printf(level, my_str, *args):

    if level == 'DEBUG':
        openmoc.log_printf(openmoc.DEBUG, my_str % args)
    elif level == 'INFO':
        openmoc.log_printf(openmoc.INFO, my_str % args)
    elif level == 'NORMAL':
        openmoc.log_printf(openmoc.NORMAL, my_str % args)
    elif level == 'SEPARATOR':
        openmoc.log_printf(openmoc.SEPARATOR, my_str % args)
    elif level == 'HEADER':
        openmoc.log_printf(openmoc.HEADER, my_str % args)
    elif level == 'TITLE':
        openmoc.log_printf(openmoc.TITLE, my_str % args)
    elif level == 'WARNING':
        openmoc.log_printf(openmoc.WARNING, my_str % args)
    elif level == 'CRITICAL':
        openmoc.log_printf(openmoc.CRITICAL, my_str % args)
    elif level == 'RESULT':
        openmoc.log_printf(openmoc.RESULT, my_str % args)
    elif level == 'UNITTEST':
        openmoc.log_printf(openmoc.UNITTEST, my_str % args)
    elif level == 'ERROR':
        openmoc.log_printf(openmoc.ERROR, my_str % args)
Beispiel #2
0
    def _run_openmoc(self):
        """Print a variety of log messages to a log file."""

        # Set a log level which precludes some messages from being printed
        openmoc.set_log_level('NORMAL')

        # Print messages using the pure C implementation
        openmoc.log_printf(openmoc.DEBUG, 'This is a debug message')
        openmoc.log_printf(openmoc.INFO, 'This is an info message')
        openmoc.log_printf(openmoc.NORMAL, 'This is a normal message')
        openmoc.log_printf(openmoc.SEPARATOR, 'This is a separator message')
        openmoc.log_printf(openmoc.HEADER, 'This is a header message')
        openmoc.log_printf(openmoc.TITLE, 'This is a title message')
        openmoc.log_printf(openmoc.WARNING, 'This is a warning message')
        openmoc.log_printf(openmoc.CRITICAL, 'This is a critical message')
        openmoc.log_printf(openmoc.RESULT, 'This is a result message')

        # Print messages using the Python-wrapped version
        py_printf('DEBUG', 'This is a debug message')
        py_printf('INFO', 'This is an info message')
        py_printf('NORMAL', 'This is a normal message')
        py_printf('SEPARATOR', 'This is a separator message')
        py_printf('HEADER', 'This is a header message')
        py_printf('TITLE', 'This is a title message')
        py_printf('WARNING', 'This is a warning message')
        py_printf('CRITICAL', 'This is a critical message')
        py_printf('RESULT', 'This is a result message: %d', 5)
Beispiel #3
0
def py_printf(level, my_str, *args):
    """Print a log message to the screen and the log file.

    This method is a wrapper to the log_printf C++ routine. It allows for
    formatted messages to be printed to the screen in a similar fashion to the
    C/C++ printf method, but with additional formatting provided by the OpenMOC
    logging utilities.

    Parameters
    ----------
    level : str
        The logging level for this message (i.e., 'NORMAL')
    my_str : str
        The string to print to the screen
    *args : list
        A variable length list of values for the message string

    Examples
    --------
    An example of how this may be used in a OpenMOC Python script is as follows:

        >>> value1 = 25
        >>> value2 = 26.0
        >>> log.py_printf('NORMAL', 'My name is Will and I am %d going on ' \
                         '%f years of age', value1, value2)

    """

    if level == 'DEBUG':
        openmoc.log_printf(openmoc.DEBUG, my_str % args)
    elif level == 'INFO':
        openmoc.log_printf(openmoc.INFO, my_str % args)
    elif level == 'NORMAL':
        openmoc.log_printf(openmoc.NORMAL, my_str % args)
    elif level == 'SEPARATOR':
        openmoc.log_printf(openmoc.SEPARATOR, my_str % args)
    elif level == 'HEADER':
        openmoc.log_printf(openmoc.HEADER, my_str % args)
    elif level == 'TITLE':
        openmoc.log_printf(openmoc.TITLE, my_str % args)
    elif level == 'WARNING':
        openmoc.log_printf(openmoc.WARNING, my_str % args)
    elif level == 'CRITICAL':
        openmoc.log_printf(openmoc.CRITICAL, my_str % args)
    elif level == 'RESULT':
        openmoc.log_printf(openmoc.RESULT, my_str % args)
    elif level == 'ERROR':
        openmoc.log_printf(openmoc.ERROR, my_str % args)
Beispiel #4
0
    def _run_openmoc(self):
        """Print a variety of log messages to a log file."""

        # Set a log level which precludes some messages from being printed
        openmoc.set_log_level('NORMAL')

        # Print messages using the pure C implementation
        openmoc.log_printf(openmoc.DEBUG, 'This is a debug message')
        openmoc.log_printf(openmoc.INFO, 'This is an info message')
        openmoc.log_printf(openmoc.NORMAL, 'This is a normal message')
        openmoc.log_printf(openmoc.SEPARATOR, 'This is a separator message')
        openmoc.log_printf(openmoc.HEADER, 'This is a header message')
        openmoc.log_printf(openmoc.TITLE, 'This is a title message')
        openmoc.log_printf(openmoc.WARNING, 'This is a warning message')
        openmoc.log_printf(openmoc.CRITICAL, 'This is a critical message')
        openmoc.log_printf(openmoc.RESULT, 'This is a result message')

        # Print messages using the Python-wrapped version
        py_printf('DEBUG', 'This is a debug message')
        py_printf('INFO', 'This is an info message')
        py_printf('NORMAL', 'This is a normal message')
        py_printf('SEPARATOR', 'This is a separator message')
        py_printf('HEADER', 'This is a header message')
        py_printf('TITLE', 'This is a title message')
        py_printf('WARNING', 'This is a warning message')
        py_printf('CRITICAL', 'This is a critical message')
        py_printf('RESULT', 'This is a result message: %d', 5)
Beispiel #5
0
def py_printf(level, my_str, *args):
    """Print a log message to the screen and the log file.

    This method is a wrapper to the log_printf C++ routine. It allows for
    formatted messages to be printed to the screen in a similar fashion to the
    C/C++ printf method, but with additional formatting provided by the OpenMOC
    logging utilities.

    Parameters
    ----------
    level : str
        The logging level for this message (i.e., 'NORMAL')
    my_str : str
        The string to print to the screen
    *args : list
        A variable length list of values for the message string

    Examples
    --------
    An example of how this may be used in a OpenMOC Python script is as follows:

        >>> value1 = 25
        >>> value2 = 26.0
        >>> log.py_printf('NORMAL', 'My name is Will and I am %d going on ' \
                         '%f years of age', value1, value2)

    """

    if level == 'DEBUG':
        openmoc.log_printf(openmoc.DEBUG, my_str % args)
    elif level == 'INFO':
        openmoc.log_printf(openmoc.INFO, my_str % args)
    elif level == 'NORMAL':
      openmoc.log_printf(openmoc.NORMAL, my_str % args)
    elif level == 'SEPARATOR':
        openmoc.log_printf(openmoc.SEPARATOR, my_str % args)
    elif level == 'HEADER':
        openmoc.log_printf(openmoc.HEADER, my_str % args)
    elif level == 'TITLE':
        openmoc.log_printf(openmoc.TITLE, my_str % args)
    elif level == 'WARNING':
        openmoc.log_printf(openmoc.WARNING, my_str % args)
    elif level == 'CRITICAL':
        openmoc.log_printf(openmoc.CRITICAL, my_str % args)
    elif level == 'RESULT':
        openmoc.log_printf(openmoc.RESULT, my_str % args)
    elif level == 'ERROR':
        openmoc.log_printf(openmoc.ERROR, my_str % args)
Beispiel #6
0
def py_printf(level, my_str, *args):

  if level == 'DEBUG':
    openmoc.log_printf(openmoc.DEBUG, my_str % args)
  elif level == 'INFO':
    openmoc.log_printf(openmoc.INFO, my_str % args)
  elif level == 'NORMAL':
    openmoc.log_printf(openmoc.NORMAL, my_str % args)
  elif level == 'SEPARATOR':
    openmoc.log_printf(openmoc.SEPARATOR, my_str % args)
  elif level == 'HEADER':
    openmoc.log_printf(openmoc.HEADER, my_str % args)
  elif level == 'TITLE':
    openmoc.log_printf(openmoc.TITLE, my_str % args)
  elif level == 'WARNING':
    openmoc.log_printf(openmoc.WARNING, my_str % args)
  elif level == 'CRITICAL':
    openmoc.log_printf(openmoc.CRITICAL, my_str % args)
  elif level == 'RESULT':
    openmoc.log_printf(openmoc.RESULT, my_str % args)
  elif level == 'UNITTEST':
    openmoc.log_printf(openmoc.UNITTEST, my_str % args)
  elif level == 'ERROR':
    openmoc.log_printf(openmoc.ERROR, my_str % args)