当前位置: 首页>>代码示例>>Python>>正文


Python LoggerFactory.getILoggerFactory方法代码示例

本文整理汇总了Python中org.slf4j.LoggerFactory.getILoggerFactory方法的典型用法代码示例。如果您正苦于以下问题:Python LoggerFactory.getILoggerFactory方法的具体用法?Python LoggerFactory.getILoggerFactory怎么用?Python LoggerFactory.getILoggerFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.slf4j.LoggerFactory的用法示例。


在下文中一共展示了LoggerFactory.getILoggerFactory方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setLogLevel

# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
def setLogLevel(level, loggerName='ROOT', temporary=True):
    """Set the log level for the given logger.
    
    Args:
        level: Logging level to set. Valid levels are 'TRACE', 'DEBUG', 'INFO',
               'WARN', 'ERROR', and 'OFF'.
                
    Optional Args:
        loggerName: Name of a specific 'logger'. Default value is 'ROOT'.
        temporary: Whether or not the logging level should be saved between
                   McIDAS-V sessions. Be aware that if set to True, loggerName
                   must be 'ROOT'. Default value is True.
                   
    Raises:
        ValueError: if temporary is True and loggerName is not 'ROOT'.
    """
    if not temporary:
        if loggerName != 'ROOT':
            raise ValueError(_BAD_LOGGERNAME % (loggerName))
        
        from edu.wisc.ssec.mcidasv.startupmanager.options import OptionMaster
        optMaster = OptionMaster.getInstance()
        optMaster.getLoggerLevelOption("LOG_LEVEL").setValue(level)
        optMaster.writeStartup()
        
    context = LoggerFactory.getILoggerFactory()
    logger = context.exists(loggerName)
    if not logger:
        logger = context.getLogger(loggerName)
    currentLevel = logger.getLevel()
    if not currentLevel:
        currentLevel = logger.getEffectiveLevel()
    convertedLevel = currentLevel.toLevel(level, currentLevel.INFO)
    logger.setLevel(convertedLevel)
开发者ID:davep-ssec,项目名称:mcidasv,代码行数:36,代码来源:interactive.py

示例2: getLogFile

# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
def getLogFile():
    # TODO(jon): this will likely have to change as the complexity of
    #            logback.xml increases. :(
    # should return the "default" logging context
    context = LoggerFactory.getILoggerFactory()
    assert context.getName() == 'default', _CONTEXT_ASSERT_MSG % context.getName()
    logger = context.getLogger(Logger.ROOT_LOGGER_NAME)
    # for now I'll assume that there's only ONE appender per logger
    appender = [x for x in logger.iteratorForAppenders()].pop()
    assert isinstance(appender, FileAppender), _APPENDER_ASSERT_MSG % type(appender).getCanonicalName()
    return appender.getFile()
开发者ID:RickKohrs,项目名称:mcidasv,代码行数:13,代码来源:interactive.py

示例3: __init__

# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
 def __init__(self):
     func = formData.get("func")
     result = "{}"
     resultType = "text/plain"
     if func == "reindex":
         file = formData.get("file")
         portalId = formData.get("portalId")
         portalManager = Services.getPortalManager()
         if file:
             print " * Reindexing: formData=%s" % file
             portalManager.indexObject(file)
             sessionState.set("reindex/lastResult", "success")
             result = '{ status: "ok" }'
         elif portalId:
             portal = portalManager.get(portalId)
             print " * Reindexing: Portal=%s" % portal.name
             portalManager.indexPortal(portal)
             sessionState.set("reindex/lastResult", "success")
             result = '{ status: "ok" }'
         else:
             sessionState.set("reindex/lastResult", "failed")
             result = '{ status: "failed" }'
     elif func == "get-state":
         result = '{ running: "%s", lastResult: "%s" }' % \
             (sessionState.get("reindex/running"),
              sessionState.get("reindex/lastResult"))
     elif func == "get-log":
         context = LoggerFactory.getILoggerFactory()
         logger = context.getLogger("au.edu.usq.fascinator.IndexClient")
         it = logger.iteratorForAppenders()
         appender = logger.getAppender("reindex")
         layout = HTMLLayout()
         layout.setContext(context)
         layout.setPattern("%d%level%msg")
         layout.setTitle("Index log")
         layout.start()
         result = "<table>"
         count = appender.getLength()
         if count == -1:
             result += "<tr><td>Failed</td></tr>"
         elif count == 0:
             result += "<tr><td>No logging events</td></tr>"
         else:
             for i in range(0, count):
                 event = appender.get(i)
                 result += layout.doLayout(event)
         result += "</table>"
         resultType = "text/html"
     writer = response.getPrintWriter(resultType)
     writer.println(result)
     writer.close()
开发者ID:kiranba,项目名称:the-fascinator,代码行数:53,代码来源:reindex.py

示例4: __init__

# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
 def __init__(self):
     print " * backup.py: formData=%s" % formData
     result = "{}"
     resultType = "text/plain"
     portalManager = Services.getPortalManager()
     func = formData.get("func")
     if func == "backup-view":
         print " * backup.py: backup portal %s" % portalId
         portal = portalManager.get(portalId)
         if portal:
             portalManager.backup(portal)
             sessionState.set("backup/lastResult", "success")
             result = '{ status: "ok" }'
         else:
             sessionState.set("backup/lastResult", "failed")
             result = '{ status: "failed" }'
     elif func == "get-state":
         result = '{ running: "%s", lastResult: "%s" }' % (
             sessionState.get("backup/running"),
             sessionState.get("backup/lastResult"),
         )
     elif func == "get-log":
         context = LoggerFactory.getILoggerFactory()
         logger = context.getLogger("au.edu.usq.fascinator.BackupClient")
         it = logger.iteratorForAppenders()
         appender = logger.getAppender("backup")
         layout = HTMLLayout()
         layout.setContext(context)
         layout.setPattern("%d%level%msg")
         layout.setTitle("Backup log")
         layout.start()
         result = "<table>"
         count = appender.getLength()
         if count == -1:
             result += "<tr><td>Failed</td></tr>"
         elif count == 0:
             result += "<tr><td>No logging events</td></tr>"
         else:
             for i in range(0, count):
                 event = appender.get(i)
                 result += layout.doLayout(event)
         result += "</table>"
         resultType = "text/html"
     writer = response.getPrintWriter(resultType)
     writer.println(result)
     writer.close()
开发者ID:kiranba,项目名称:the-fascinator,代码行数:48,代码来源:backup.py

示例5: setLogLevel

# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
def setLogLevel(level, loggerName='ROOT', temporary=True):
    if not temporary:
        if loggerName != 'ROOT':
            raise ValueError(_BAD_LOGGERNAME % (loggerName))
        
        from edu.wisc.ssec.mcidasv.startupmanager.options import OptionMaster
        optMaster = OptionMaster.getInstance()
        optMaster.getLoggerLevelOption("LOG_LEVEL").setValue(level)
        optMaster.writeStartup()
        
    context = LoggerFactory.getILoggerFactory()
    logger = context.exists(loggerName)
    if not logger:
        logger = context.getLogger(loggerName)
    currentLevel = logger.getLevel()
    if not currentLevel:
        currentLevel = logger.getEffectiveLevel()
    convertedLevel = currentLevel.toLevel(level, currentLevel.INFO)
    logger.setLevel(convertedLevel)
开发者ID:TimO-CIMSS,项目名称:mcidasv,代码行数:21,代码来源:interactive.py

示例6:

# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
import logging
from config import Config
from ch.qos.logback.classic import Level
from org.slf4j import LoggerFactory


# Configure the python logger
FORMAT = '%(asctime)-15s %(levelname)s %(message)s'
logging.basicConfig(format=FORMAT)

# Disable the Java logger
java_logger_context = LoggerFactory.getILoggerFactory()
root_logger = java_logger_context.getLogger("ROOT")
root_logger.setLevel(Level.OFF)

# Load the singleton configuration instance to initialize
# the 'kahuna' logger
Config()
开发者ID:nacx,项目名称:kahuna,代码行数:20,代码来源:__init__.py


注:本文中的org.slf4j.LoggerFactory.getILoggerFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。