Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Lightning talk - Logging (Dutch)

Lightning talk - Logging (Dutch)

A 5 minute lightning talk I gave to my colleagues at a&m impact internetdiensten.

Nick Groenen

February 26, 2013
Tweet

More Decks by Nick Groenen

Other Decks in Programming

Transcript

  1. Logging
    Logging is the cutting, skidding, on-site
    processing, and loading of trees or logs onto
    trucks or skeleton cars.

    View full-size slide

  2. Waarom zou ik?
    ● Wat gebeurde er?
    ● Wanneer gebeurde het?
    ● Waar gebeurde het? (en waar niet?)
    ● Welke stappen zijn uitgevoerd?
    ● En soms de waardes van parameters en
    responses

    View full-size slide

  3. Okay, maar hoe dan?
    ● Inspiratie: log4j (java)
    ○ PHP: log4php
    ○ Python: logging (In standard library!)
    ○ Ruby: log4r, logging
    include('Logger.php');
    $logger = Logger::getLogger("main");
    $logger->info("This is an informational message.");
    $logger->warn("I'm not feeling so good...");
    INFO - This is an informational message.
    WARN - I'm not feeling so good...

    View full-size slide

  4. Tips, tricks & pitfalls
    ● Gebruik verschillende levels effectief
    ○ (WARN == INFO) == False
    ● Debugging UIT op production
    ● Pas op met object/functie aanroepen
    ○ $logger->debug("Doing something with object " .
    $this->nastyLongObjectLookup()); // *yawn* App hangs

    View full-size slide

  5. Tips, tricks & pitfalls (cont)
    ● Ben duidelijk/helder
    ○ $logger->info("Gebruiker succesvol ingelogd"); // Ja
    maar wie dan?
    $logger->info("Gebruiker " . $user->id . " succesvol
    ingelogd");
    ○ $logger->warn("Onverwachte statuscode teruggekregen
    van webservice"); // Uh, welke dan?
    $logger->warn("Onverwachte statuscode " . $response-
    >code . " teruggekregen van websevice");
    $logger->debug("Response data was: " . $response-
    >data"); // Echte programmeurs hebben geen debugger
    nodig ;)

    View full-size slide

  6. Tips, tricks & pitfalls (cont)
    ● Grep, sed, awk, sort, uniq
    ● Critical/Exception?
    ○ Ja, maar ook....
    Sentry!!

    View full-size slide

  7. Now, go forth
    and log!
    Image credits
    Logging truck and bush taxi accident: Wikipedia uploader Amcaja
    The Sentry: Marvel Comics

    View full-size slide