Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: YAML for logs?

by blazar (Canon)
on Nov 25, 2006 at 17:31 UTC ( [id://586028]=note: print w/replies, xml ) Need Help??


in reply to Re: YAML for logs?
in thread YAML for logs?

Personally I hate YAML because I find it impossible to edit by hand even though people keep assuring me that it's designed for that. They're liars, all. I've found I nearly always need a computer to write the YAML for me. It's a stupid, stupid language and somehow, for some strange reason, it's the fad right now. It makes me want to puke on my shoes.

I respect your opinion very much so I'll take into account and for sure do not disregard it with an "I don't agree" a priori. I may concede on the writing bit, and indeed it seems to me that it should be easy, but I've not really done that. Seriously, I mean. But here I was more focusing on the reading bit. For example, these are the last five lines for my (Apache's) access_log at http://blazar.perlmonk.org/:

66.37.83.53 - - [24/Nov/2006:14:06:11 -0500] "GET /tmp/tesi.cls HTTP/1 +.1" 200 3104 "http://groups-beta.google.com/group/comp.text.tex/brows +e_thread/thread/674424ec76ee82eb/c3db89593b6c9774" "Mozilla/5.0 (Maci +ntosh; U; PPC Mac OS X; en) AppleWebKit/418.9 (KHTML, like Gecko) Saf +ari/419.3" 66.37.83.53 - - [24/Nov/2006:14:06:12 -0500] "GET /favicon.ico HTTP/1. +1" 404 293 "-" "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWeb +Kit/418.9 (KHTML, like Gecko) Safari/419.3" 66.249.72.12 - - [24/Nov/2006:19:40:38 -0500] "GET /robots.txt HTTP/1. +1" 404 627 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.g +oogle.com/bot.html)" 66.249.72.12 - - [24/Nov/2006:19:40:38 -0500] "GET /tmp/tesi.cls HTTP/ +1.1" 200 3104 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://ww +w.google.com/bot.html)" 64.242.88.60 - - [24/Nov/2006:23:13:04 -0500] "GET /robots.txt HTTP/1. +1" 404 292 "-" "Mozilla/4.0 compatible ZyBorg/1.0 (wn-14.zyborg@looks +mart.net; http://www.WISEnutbot.com)"

If I run them through

#!/usr/bin/perl use strict; use warnings; use Parse::AccessLogEntry; use YAML::Syck; my $p=Parse::AccessLogEntry->new; chomp, print Dump $p->parse($_) while <>; __END__

I get the following, which is only marginally more verbose than the original, but in a way that clears up the meaning of things, and IMHO largely more readable.

--- agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.9 +(KHTML, like Gecko) Safari/419.3 bytes: 3104 code: 200 date: 24/Nov/2006 diffgmt: -0500 file: /tmp/tesi.cls host: 66.37.83.53 proto: HTTP/1.1 refer: http://groups-beta.google.com/group/comp.text.tex/browse_thread +/thread/674424ec76ee82eb/c3db89593b6c9774 rtype: GET time: 14:06:11 user: "-" --- agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.9 +(KHTML, like Gecko) Safari/419.3 bytes: 293 code: 404 date: 24/Nov/2006 diffgmt: -0500 file: /favicon.ico host: 66.37.83.53 proto: HTTP/1.1 refer: "-" rtype: GET time: 14:06:12 user: "-" --- agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/ +bot.html) bytes: 627 code: 404 date: 24/Nov/2006 diffgmt: -0500 file: /robots.txt host: 66.249.72.12 proto: HTTP/1.1 refer: "-" rtype: GET time: 19:40:38 user: "-" --- agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/ +bot.html) bytes: 3104 code: 200 date: 24/Nov/2006 diffgmt: -0500 file: /tmp/tesi.cls host: 66.249.72.12 proto: HTTP/1.1 refer: "-" rtype: GET time: 19:40:38 user: "-" --- agent: Mozilla/4.0 compatible ZyBorg/1.0 (wn-14.zyborg@looksmart.net; +http://www.WISEnutbot.com) bytes: 292 code: 404 date: 24/Nov/2006 diffgmt: -0500 file: /robots.txt host: 64.242.88.60 proto: HTTP/1.1 refer: "-" rtype: GET time: 23:13:04 user: "-"

I can imagine further "advantages" if some hierarachical info were to be included.

Replies are listed 'Best First'.
Re^3: YAML for logs?
by diotalevi (Canon) on Nov 25, 2006 at 18:29 UTC

    I'm bitchy about YAML purely because of the last dozen times I tried writing some by hand, I failed because YAML syntax is more obscure than my current understanding. I recall going to the YAML web site to find a quick description but there was just a big reference doc and that was more overhead than I wanted. YAML is supposed to be simple, right? Well it's not. Actually, I don't think YAML is supposed to be simple. I'd rather write my data in Perl or lisp. The former is common to everyon here and the latter is so simple that any moron can write it.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

      The docs are rather weighty. What I used as an introduction to the syntax was Ingy's YAML docs (see YAML Terminology)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://586028]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-03-29 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found