Home>
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.
TypeError: log () missing 1 required positional argument: 'msg'
Applicable source code
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 [0]! = '$': # 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 [0] if gps.timestamp [0]<24 else gps.timestamp [0]-24
#print ('% 2d:% 02d:% 04.1f'% (h, gps.timestamp [1], gps.timestamp [2]))
latlon = (gps.latitude [0], gps.longitude [0])
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
-
Answer # 2
logger.log (latlon)
What kind of argument is this log function?
And what type does this latlon variable have?
Related articles
- [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
Trends
log
is called bylog (level, msg, * args, ** kwargs)
, and the log level is specified as an integer.Since it is
logger.setLevel (10)
, it is output only when a value greater than10
is specified.Level is
CRITICAL
>ERROR
>WARNING
>INFO
>DEBUG
SoIt will be said that.