I'm a program beginner.
I am using the GPS module to measure latitude and longitude, but at first I was outputting it with a print statement, but this time I want to output latitude and longitude to the log file, and when I tried to run this error A sentence came out. I would like to know why such an error message appears.
Applicable source code
TypeError: log () missing 1 required positional argument: 'msg'
import serial import micropyGPS import threading import time import logging #Set log output name logger = logging.getLogger ('GPSTest') # logger.setLevel (10) # fh = logging.FileHandler ('GPS.log') logger.addHandler (fh) gps = micropyGPS.MicropyGPS (9, 'dd') # Create a MicroGPS object. # Arguments are time zone time difference and output format def rungps (): # read GPS module and update GPS object s = serial.Serial ('/ dev/serial0', 9600, timeout = 10) s.readline () # discard the first line because halfway data can be read while True: sentence = s.readline (). decode ('utf-8') # Read GPS data and convert it to a string if sentence ! = '$': # throw away unless it starts with '$' continue for x in sentence: # Parse the read string and add/update data to the GPS object gps.update (x) gpsthread = threading.Thread (target = rungps, args = ()) # Create a thread to execute the above function gpsthread.daemon = True gpsthread.start () # start thread while True: if gps.clean_sentences>1: # output when some data is collected #h = gps.timestamp  if gps.timestamp <24 else gps.timestamp -24 #print ('% 2d:% 02d:% 04.1f'% (h, gps.timestamp , gps.timestamp )) latlon = (gps.latitude , gps.longitude ) logger.log (latlon) #rint ('Sea level:% f'% gps.altitude) #rint (gps.satellites_used) #rint ('Satellite Number: (Elevation, Azimuth, Signal to Noise Ratio)') for k, v in gps.satellite_data.items (): print ('% d:% s'% (k, v)) print ('') time.sleep (3.0)
Since I wanted only latitude and longitude, I commented out the other output.Supplemental information (FW/tool version etc.)
Please provide more information here.
Answer # 1
logis called by
log (level, msg, * args, ** kwargs), and the log level is specified as an integer.
logger.log (99, "!!!!!!") Or, using a constant, logger.log (logging.INFO, "something")
Since it is
logger.setLevel (10), it is output only when a value greater than
logger.setLevel (logging.INFO) logger.error ("AAAAA") # ⇒ output logger.debug ("AAAAA") # ⇒ No output logger.log (logging.ERROR, "AAAAA") # same as logger.error ("AAAAA")
It will be said that.
Answer # 2
What kind of argument is this log function?
And what type does this latlon variable have?
- [python] graphviz output format error
- python - about the error log output method
- python: an error occurs that the type is different in the output using dict key values
- python - i want to solve the problem that i get the error typeerror: xxxxxxxx takes no arguments
- python - [pytorch] i want to get the output of the middle layer of a complicated model
- python 3x - the output result of the numerical value obtained by web scraping becomes 0
- python - an error occurs in the if statement program that compares the size of numbers
- python - sklearn, svm error
- about image output of python
- extract from python dat data and output to csv
- python - error in image binarization using cv2adaptivethreshold function
- python - in raspberry pi, the error occurs only in the case of the automatic start program using systemd
- python - the py file cannot be executed in the task scheduler 0x2 error
- python - categorical_crossentoropy error does not resolve
- python - how to resolve attribute error
- readcsv error in python
- python - i want to display an image with pysimplegui, but an error occurs
- python - error when scraping with selenium and firefox
- python - typeerror when calculating the array of images called by imageopen ()
- python - i get an error when connecting to a voice channel with discordpy