On Mar 26, 2012, at 10:38 AM, [email protected] wrote:
> I agree with just about everything here, except I think we should be
> able to do better than the `format="opaque string"ยด part.
In principle I agree, but I'm not sure about how to do that _exactly now_.
Whereas today, immediately, all log messages could be written in the style I
suggested and it would be a big improvement.
> Logging in the style you outlined here preserves the structure of the
> information, but it omits any consistent way to identify what the
> structure is. It seems to leave only two possibilities:
>
> - Compare the format string to certain well-known format strings and
> use a match (if found) to make decisions based on a priori knowledge
> about the additional items in the log event.
Previous (limited) experience with internationalization efforts lead me to
believe that looking at well-known format strings to determine meaning is the
state of the art.
> - Compare the set of keys in the log event to certain well-known sets
> and use a match there to make the same kind of decision.
>
> Neither of these sounds like a good thing.
Still, a pretty substantial improvement over running a regex over a string in a
quasi-structured log file after the fact (IMHO).
> Divmod experimented with marking log events with interfaces that
> documented the structure and semantics of the log event carrying them.
> This didn't get very far, and perhaps had problems of its own, but even
> it seemed preferable to either of the above options.
What I'd really like to do is to have some kind of log object built up like
this:
logger = Logger(module=__name__)
class DebugFoo(logger.message()):
"""wouldn't it be great if such messages were explained in detail"""
audience=developers; importance=medium; format="foo %(foo)d happened";
logID=UUID('7dc1c45b-4eb7-4a3f-b751-ee6b500f11ce')
anythingElseInteresting="otherstuff"
def onFoo(someFoo):
DebugFoo.emit(foo=7)
and while this isn't hard to implement, it's also not implemented already, but
the format= stuff is. So my suggestion was not intended to say we should stop
here, but rather, while we're figuring out better stuff to do, nobody should
ever write a 'log.msg("some static " + thing)' again :).
-glyph
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python