Contents Default Dancer logging Using Logger::LogReport

Slides:



Advertisements
Similar presentations
MY NCBI (module 4.5). MODULE 4.5 PubMed/How to Use MY NCBI Instructions - This part of the:  course is a PowerPoint demonstration intended to introduce.
Advertisements

1.  Understanding about How to Working with Server Side Scripting using PHP Framework (CodeIgniter) 2.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
ACS Logging System Concepts and Example H.Sommer (Restructured, based on slides from previous years) UTFSM Valparaiso, Chile, Nov ACS Logging System.
Salesforce.com Web to Leads. Unit Name Web to Leads A web to lead provides users the ability to gather information from their website visitors which automatically.
07/19/04 NorCal OAUG Training Day, Paper 2.4 John Peters, JRPJR, Inc.1 Oracle Workflow Notifications John Peters JRPJR, Inc.
Microsoft ® Official Course Monitoring and Troubleshooting Custom SharePoint Solutions SharePoint Practice Microsoft SharePoint 2013.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
(c) Manzur Ashraf, Short course, KFUPM PHP & MySQL 1 Basic PHP Class 2.
User Interface Design using jQuery Mobile CIS 136 Building Mobile Apps 1.
Logging Best Practices Dubna 2012 Benedicto Fernandez Software Engineer CERN / GS-AIS.
BEST PRACTICES - Java By Configuration Use global-forwards/results Helps to avoid duplicate jsp files and redundancy forward mapping.
Designing For Testability. Incorporate design features that facilitate testing Include features to: –Support test automation at all levels (unit, integration,
LogBox Enterprise Logging Brad Wood
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
Oracle Data Integrator Procedures, Advanced Workflows.
8 th Semester, Batch 2008 Department Of Computer Science SSUET.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Implementing The Middle Tier These slides.
ICM – API Server & Forms Gary Ratcliffe.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Enterprise Library Caching Application Block Peter Provost Software Design Engineer Ron Jacobs Product Manager Scott Densmore Software Design Engineer.
1 CS 3870/CS 5870: Note07 Prog 4. Master Pages Creating a master page based on another master page MainMasterPage –For all Progs and Tests Prog4MasterPage.
Exception Handling in C + + Introduction Overview of C++ Exception Handling Designing With Exceptions Exception Handling Philosophies Conclusion.
PHP Exception Handling How to handle and create user-defined exceptions Mario Peshev Technical Trainer Software University
Martin Kruliš Who is General Failure and why is he reading my disk? by Martin Kruliš (v1.0)1.
Python: Building Geoprocessing Tools David Wynne, Ghislain Prince.
Emdeon Office Batch Management Services This document provides detailed information on Batch Import Services and other Batch features.
Advanced Informer Features
Logging Microservice Deep Dive
3. System Task Botton in Form (Uploader Function)
ASP.NET Programming with C# and SQL Server First Edition
Partners – MaaS360 Portal Management
Project Management: Messages
Interrupts and exceptions
Chapter 6 CS 3370 – C++ Functions.
z/Ware 2.0 Technical Overview
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
Logger, Assert and Invariants
Persistence – Iteration 4 Vancouver Bootcamp
Troubleshooting with cim/trm logs
PYTHON: AN INTRODUCTION
Computer Programming I
CMPE 280 Web UI Design and Development October 19 Class Meeting
Exceptions Lightning Talk on Exceptions MiltonKeynes.pm 12-Jan-2009
Processes The most important processes used in Web-based systems and their internal organization.
Texting Demo This is a prototype – not ready to ship yet
We now will look at options for saving searches in CINAHL
The HP OpenVMS Itanium® Calling Standard
Populating a Data Warehouse
(Includes setup) FAQ ON DOCUMENTS (Includes setup)
Adding and editing users
Populating a Data Warehouse
Adding and Editing Users
Exceptions Problems in a Java program may cause exceptions or errors representing unusual or invalid processing. An exception is an object that defines.
Populating a Data Warehouse
TaxSlayer Multi-Factor Authentication
Exception Handling Chapter 9 Edited by JJ.
Getting Started: Amazon AWS Account Creation
Training Module Introduction to the TB9100/P25 CG/P25 TAG Customer Service Software (CSS) Describes Release 3.95 for Trunked TB9100 and P25 TAG Release.
Testing, debugging, and using support libraries
This is the Sign In page for the Dashboard
IBM SCPM Basic Navigation
How to debug a website using IE F12 tools
Training 101 : Accessing iBoomerang Tools
Wells Fargo Toolkit – CreativeBuilder Reference Guide
(Includes setup) FAQ ON DOCUMENTS (Includes setup)
PHP-II.
Corporate Training Center
Framework Anil
Presentation transcript:

Dancer2::Logger::LogReport and Dancer2::Plugin::LogReport Andy Beverley andybev / andy@andybev.com

Contents Default Dancer logging Using Logger::LogReport Adding Plugin::LogReport Handling errors normally Handling errors using Plugin::LogReport Translations

Why? Combine user and system messages Easily catch user errors Keep code to a minimum

Default Dancer logging Call logging functions: core debug info warning error Sent to logging engines External modules need to depend on Dancer

Using Dancer2::Logger::LogReport Be default, behaves same as console logger Can use Log::Report in any external module Access to many “dispatchers”: Syslog, File, Log4perl, Callback Access to additional logging levels Use dispatcher mode to filter messages

Log::Report concept Syslog trace Log::Report::Exception notice error Log::Report::Message File Dispatchers

Reporting messages trace (program, debug) assert (program, unexpected condition) info (program, verbose) notice (program) success (Plugin::LogReport only) warning (program) mistake (user) error (user, fatal) fault (system, fatal) alert (system, fatal) failure (system, fatal) panic (program, fatal)

Adding Dancer2::Plugin::LogReport Provides additional Log::Report keywords Saves messages to the session use Dancer2; use Log::Report (); # Not always needed use Dancer2::Plugin::LogReport; get '/myroute' => sub { notice "Dancer conference this week"; template 'myroute'; }

Adding Dancer2::Plugin::LogReport Provides additional Log::Report keywords Saves messages to the session [% FOREACH msg IN messages %] <div class="alert alert-[% msg.bootstrap_color %]"> [% msg.toString %] </div> [% END %]

Adding Dancer2::Plugin::LogReport Handles application exceptions Displays generic error if show_errors: 0 Messages as Dancer2::Plugin::LogReport::Message (extends Log::Report::Message) Dispatcher mode defines what to log (line number, stack trace etc)

Handling errors - normally Return errors from subroutine? Use die and eval or similar? Sub update { ... die "Invalid email address"; } eval { MyApp::Task->new($task) }; if (hug) { messageAdd( { danger => bleep } ); } else { forwardHome( { success => 'Updated successfully' }

Handling errors - Plugin::LogReport Use error() By default forwards to home page and displays error Use process() to catch and display error automatically Minimal code!

Handling errors if (process sub { Lenio::Task->new($task) } ) { success "Created successfully"; } # error handled automatically

Updating settings any '/settings' => sub { my $settings = current_settings(); if (my $new_settings = param ...) { $settings->new_values($new_settings); if (process sub { $settings->write } ) { success "Settings updated"; } } template 'settings' => { settings => $settings; }; };

Translations Use: __ "Text to translate"; __x "Invalid name: {name}", name => $name; __nx "one file", "{_count} files", $nr_files; By default, no translations

Translations - Template::Toolkit Various methods in TT, e.g. [% 'Translate me please' | loc %] [% 'Hello {name}' | loc(name => client.name) %] Needs adding to the plugin! Text extracted from templates / source

Adding a translator use Log::Report::Translator::POT; use Dancer2::Plugin::LogReport 'default'; (textdomain 'default')->configure( translator => Log::Report::Translator::POT->new( lexicon => 'path/to/messages' ) );

Adding a translator e.g. LC_MESSAGES=nl_NL.utf8 Looks for nl_NL.utf8 translation table Override in dispatcher (e.g. syslog): locale => 'en_GB.UTF-8'

Demo

Message objects Log::Report::Exception object contains: Exception level (reason for message) Caller stack $!, $? Log::Report::Message object contains string to be translated (msgid) parameters to be filled in textdomain

Other features Messages can be added to a class: warning __"Do <b>not</b> do that!", _class => 'html'; [% IF message.inClass("html") %] [% message %] [% ELSE %] [% message | html_entity %] [% END %]

Other points Use syslog for email notifications Dispatcher format? Multiple apps

DBIC logging use Log::Report::DBIC::Profiler; $schema->storage->debugobj( Log::Report::DBIC::Profiler->new ); $schema->storage->debug(1); Oct 21 16:24:01 myhost GADS[15722]: INSERT INTO "user" ( "username") VALUES ( ? ) RETURNING "id": 'andy' Oct 21 16:24:01 myhost GADS[15722]: execution took 0.0004 seconds

DBIC exceptions # Doesn't work in DBIC eval{} $schema->exception_action(sub { panic @_ });

Questions?