jkakar / logfmt-python Goto Github PK
View Code? Open in Web Editor NEWPython package for parsing log lines in the logfmt style.
License: MIT License
Python package for parsing log lines in the logfmt style.
License: MIT License
% python
Python 3.9.5 (default, May 11 2021, 08:20:37)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import logfmt.parser
>>> logfmt.parser.parse_line("foo=bar=bat")
{'foo': 'bar', 'bat': True}
By my reading of https://pkg.go.dev/github.com/kr/logfmt, this should be {'foo': 'bar=bat'}
, since string_byte
includes =
(though ident_byte
does not).
Point the updated project link to https://github.com/jteppinette/python-logfmter
Hi,
I am trying to use LogfmtFormatter as such:
h = Handler()
h.setFormatter(LogfmtFormatter())
And getting following error:
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.7/logging/init.py", line 1025, in emit
msg = self.format(record)
File "/usr/lib/python3.7/logging/init.py", line 869, in format
return fmt.format(record)
File "/usr/lib/python3.7/site-packages/logfmt/formatter.py", line 27, in format
'at=%' % record.levelname,
ValueError: incomplete format
Call stack:
File "my.py", line 72, in
logger.info('Hello, World!')
Message: 'Hello, World!'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.7/logging/init.py", line 1025, in emit
msg = self.format(record)
File "/usr/lib/python3.7/logging/init.py", line 869, in format
return fmt.format(record)
File "/usr/lib/python3.7/site-packages/logfmt/formatter.py", line 27, in format
'at=%' % record.levelname,
ValueError: incomplete format
Call stack:
File "my.py", line 73, in
logger.debug('Hello, World!')
Message: 'Hello, World!'
Arguments: ()
Looking at the code, is a %s missing?
I'm trying to parse quotes on logfmt format but, the value after the quote become new key with value "True".
iimport logfmt from logfmt import format import io raw_text=io.StringIO("ts=1579739313\"80007168") rawdata=logfmt.parse(raw_text) for i in rawdata: print(i)
output
{'ts': '1579739313', '80007168': True}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.