PK N>W
_H H build.xml
PK N>=> > commands.py# Here you can create play commands that are specific to the module, and extend existing commands
MODULE = 'log4play'
# Commands that are specific to your module
COMMANDS = ['log4play:hello']
def execute(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "log4play:hello":
print "~ Hello"
# This will be executed before any command (new, run...)
def before(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
# This will be executed after any command (new, run...)
def after(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "new":
pass
PK )w>^$ $ manifestversion=0.0.1
frameworkVersions=1.2
PK R>^P P README.textileh1. Play! Framework Log4Play Module
h2. Felipe Oliveira & Deepthi Rallabandi
http://playframework.info
http://geeks.aretotally.in
http://mashup.fm
http://twitter.com/_felipera
h3. 1) Introduction
Log4Play is a module that provides a log4j appender which publishes log entries to an EventStream.
The module also provides an user interface which uses a WebSocket creating a live stream of log messages.
You can use this user interface to look at the logs of your application without needing to login to the actual box.
h3. 2) Installation
Under dependencies.yml:
require:
- play -> log4play 0.0.1
h3. 3) Live Demo
A live demo is available at http://log4play.mashup.fm:9030/@logs.
As soon as you enable the module on your application you should have the same UI available as well under /@logs.
h3. 4) Source Code
The source code is available on Github at https://github.com/feliperazeek/log4play.
h3. 5) Changelog
May 13th 2011 - Version 0.0.1: First Release.
h3. 6) Roadmap
* Extend the UI to listen on multiple WebSockets to allow to receive messages from a whole cluster.
PK `>? app/controllers/Log4Play.java/**
* Copyright (c) 2011 - 2011, Verizon , All rights reserved.
*
* @author Deepthi
*/
package controllers;
import play.Logger;
import play.libs.F.EventStream;
import play.libs.F.Promise;
import play.mvc.Controller;
import play.mvc.WebSocketController;
// TODO: Auto-generated Javadoc
/**
* The Class Log4Play.
*/
public class Log4Play extends Controller {
/**
* Index.
*/
public static void index() {
render();
}
/**
* The Class WebSocket.
*/
public static class WebSocket extends WebSocketController {
/**
* Index.
*/
public static void index() {
EventStream loggingStream = play.modules.log4play.LogStream.getStream();
while (inbound.isOpen()) {
try {
Promise promise = loggingStream.nextEvent();
play.modules.log4play.Log4PlayEvent event = await(promise);
outbound.sendJson(event);
} catch (Throwable t) {
Logger.error(play.modules.log4play.ExceptionUtil.getStackTrace(t));
}
}
}
}
}PK j>( app/jobs/LoggerTestJob.java/**
* Copyright 2011 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author Felipe Oliveira (http://mashup.fm)
*
*/
package jobs;
import play.Logger;
import play.Play;
import play.jobs.Job;
import play.jobs.OnApplicationStart;
// TODO: Auto-generated Javadoc
/**
* The Class LoggerTestJob.
*/
@OnApplicationStart(async = true)
public class LoggerTestJob extends Job {
/**
* Debug Messages for Testing
*
* @see play.jobs.Job#doJob()
*/
@Override
public void doJob() {
if (Play.mode.equals(Play.Mode.PROD)) {
return;
}
int i = 0;
while (true) {
i++;
String msg = "";
for (int x = 0; x < 5; x++) {
msg = msg + "Debug Message " + i + " ";
}
Logger.debug(msg);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
Logger.error(play.modules.log4play.ExceptionUtil.getStackTrace(e));
}
}
}
}
PK >C app/views/main.html
#{get 'title' /}
#{get 'moreStyles' /}
#{get 'moreScripts' /}
#{doLayout /}
PK p>-e app/views/errors/404.html
Not found
#{if play.mode.name() == 'DEV'}
#{404 result /}
#{/if}
#{else}
PK N>W
_H H
bin/build.xml
PK N>=> > bin/commands.py# Here you can create play commands that are specific to the module, and extend existing commands
MODULE = 'log4play'
# Commands that are specific to your module
COMMANDS = ['log4play:hello']
def execute(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "log4play:hello":
print "~ Hello"
# This will be executed before any command (new, run...)
def before(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
# This will be executed after any command (new, run...)
def after(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "new":
pass
PK )>Y , bin/app/controllers/Log4Play$WebSocket.class 2 "app/controllers/Log4Play$WebSocket WebSocketController ()V Code java/lang/Error CUnresolved compilation problems:
The declared package "controllers" does not match the expected package "app.controllers"
The import play.Logger cannot be resolved
The import play.libs cannot be resolved
The import play.libs cannot be resolved
The import play.mvc cannot be resolved
The import play.mvc cannot be resolved
Controller cannot be resolved to a type
The method render() is undefined for the type Log4Play
WebSocketController cannot be resolved to a type
EventStream cannot be resolved to a type
play cannot be resolved to a type
play cannot be resolved
inbound cannot be resolved
Promise cannot be resolved to a type
play cannot be resolved to a type
play cannot be resolved to a type
outbound cannot be resolved
Throwable cannot be resolved to a type
Logger cannot be resolved
play cannot be resolved
(Ljava/lang/String;)V LineNumberTable LocalVariableTable this $Lapp/controllers/Log4Play$WebSocket; index Unresolved compilation problems:
EventStream cannot be resolved to a type
play cannot be resolved to a type
play cannot be resolved
inbound cannot be resolved
Promise cannot be resolved to a type
play cannot be resolved to a type
play cannot be resolved to a type
outbound cannot be resolved
Throwable cannot be resolved to a type
Logger cannot be resolved
play cannot be resolved
SourceFile
Log4Play.java InconsistentHierarchy InnerClasses app/controllers/Log4Play WebSocket MissingTypes ! 4
Y
*
Y $
PK )>ܷ " bin/app/controllers/Log4Play.class 2 app/controllers/Log4Play
Controller ()V Code java/lang/Error CUnresolved compilation problems:
The declared package "controllers" does not match the expected package "app.controllers"
The import play.Logger cannot be resolved
The import play.libs cannot be resolved
The import play.libs cannot be resolved
The import play.mvc cannot be resolved
The import play.mvc cannot be resolved
Controller cannot be resolved to a type
The method render() is undefined for the type Log4Play
WebSocketController cannot be resolved to a type
EventStream cannot be resolved to a type
play cannot be resolved to a type
play cannot be resolved
inbound cannot be resolved
Promise cannot be resolved to a type
play cannot be resolved to a type
play cannot be resolved to a type
outbound cannot be resolved
Throwable cannot be resolved to a type
Logger cannot be resolved
play cannot be resolved
(Ljava/lang/String;)V LineNumberTable LocalVariableTable this Lapp/controllers/Log4Play; index YUnresolved compilation problem:
The method render() is undefined for the type Log4Play
SourceFile
Log4Play.java InconsistentHierarchy InnerClasses "app/controllers/Log4Play$WebSocket WebSocket MissingTypes ! 4
Y
*
Y
PK >s+ + bin/app/jobs/LoggerTestJob.class 2 app/jobs/LoggerTestJob Job ()V Code java/lang/Error Unresolved compilation problems:
The declared package "jobs" does not match the expected package "app.jobs"
The import play.Logger cannot be resolved
The import play.Play cannot be resolved
The import play.jobs cannot be resolved
The import play.jobs cannot be resolved
OnApplicationStart cannot be resolved to a type
The attribute async is undefined for the annotation type OnApplicationStart
Job cannot be resolved to a type
Override cannot be resolved to a type
Play cannot be resolved
Play cannot be resolved to a variable
String cannot be resolved to a type
Logger cannot be resolved
Thread cannot be resolved
InterruptedException cannot be resolved to a type
Logger cannot be resolved
play cannot be resolved
(Ljava/lang/String;)V LineNumberTable LocalVariableTable this Lapp/jobs/LoggerTestJob; doJob RuntimeInvisibleAnnotations
LOverride; KUnresolved compilation problems:
Override cannot be resolved to a type
Play cannot be resolved
Play cannot be resolved to a variable
String cannot be resolved to a type
Logger cannot be resolved
Thread cannot be resolved
InterruptedException cannot be resolved to a type
Logger cannot be resolved
play cannot be resolved
SourceFile LoggerTestJob.java InconsistentHierarchy MissingTypes ! 4
Y
4
Y &