mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 19:28:26 +08:00
doc/writing_a_driver: use logging.getLogger
This commit is contained in:
parent
c259c4f46f
commit
3a784e3382
@ -121,9 +121,14 @@ The program below exemplifies how to use logging: ::
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
from artiq.tools import verbosity_args, init_logger
|
||||
|
||||
|
||||
# get a logger that prints the module name
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_argparser():
|
||||
parser = argparse.ArgumentParser(description="Logging example")
|
||||
parser.add_argument("--someargument",
|
||||
@ -137,11 +142,11 @@ The program below exemplifies how to use logging: ::
|
||||
args = get_argparser().parse_args()
|
||||
init_logger(args) # This initializes logging system log level according to -v/-q args
|
||||
|
||||
logging.debug("this is a debug message")
|
||||
logging.info("this is an info message")
|
||||
logging.warning("this is a warning message")
|
||||
logging.error("this is an error message")
|
||||
logging.critical("this is a critical message")
|
||||
logger.debug("this is a debug message")
|
||||
logger.info("this is an info message")
|
||||
logger.warning("this is a warning message")
|
||||
logger.error("this is an error message")
|
||||
logger.critical("this is a critical message")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user