Giter VIP home page Giter VIP logo

logfmt-python's Issues

"foo=bar=bat" parsed incorrectly

% 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).

"ValueError: incomplete format" on LogfmtFormatter

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?

Parsing the quotes on logfmt format

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}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.