Home | History | Annotate | Download | only in utils
      1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 """Helper functions common to native, java and host-driven test runners."""
      6 
      7 import collections
      8 import logging
      9 
     10 from devil.utils import logging_common
     11 
     12 
     13 CustomFormatter = logging_common.CustomFormatter
     14 
     15 
     16 _WrappedLoggingArgs = collections.namedtuple(
     17     '_WrappedLoggingArgs', ['verbose'])
     18 
     19 
     20 def SetLogLevel(verbose_count, add_handler=True):
     21   """Sets log level as |verbose_count|.
     22 
     23   Args:
     24     verbose_count: Verbosity level.
     25     add_handler: If true, adds a handler with |CustomFormatter|.
     26   """
     27   logging_common.InitializeLogging(
     28       _WrappedLoggingArgs(verbose_count),
     29       handler=None if add_handler else logging.NullHandler())
     30