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?
- data output error to python csv file
- python: an error occurs that the type is different in the output using dict key values
- python - i get an error when connecting to a voice channel with discordpy
- i get a no module named error when i try to run a program in python
- python - [selenium] i want to click the dropdown, but an error is returned
- python - i want to extract only the matching lines in two csv and output a new csv
- python 3x - i want to output a character string that contains a specific character string
- an init error that is not used in python and ldl appears
- python - 'numpyndarray' object has no attribute'numpy' error
- python - 'numpyndarray' object has no attribute'append' error
- python 3x - i want to output the python3 ping result to csv
- python - when using pil, an error screen is displayed
- python - i get an argument must be int or float error in django
- reading python text module assignment error occurred
- python - i get an error code of'int' object is not callable
- [python] no error occurs, but it is not executed i would like to help you
- i want to create a for statement to output the day of the week in python
- to get the same output without using python dict
- python - i want to know the cause of the error that occurs when kernel density estimation is performed with high-dimensional dat
- python - i want to resolve the error message
- python - data measurement by increasing the number of channels
- python - please tell me how to automatically update the temperature, humidity and barometric pressure display using bme280 on ra
- python delete files after uploading
- python - i want to get a string only when spaces and hyphens are exact matches, but i can't process it with one code
- in python, i want to extract an array from a number reference
- about how to eliminate the error when updating python with raspbian (buster)
- python - weather forecast scraping error
- json format decode error python
- python scraping jsonloads () jsondecodeerror
- i want to change a string to hexadecimal in python