#goose-log
goose-log is a client-side logging framework written in Scala using Scalatra and logula
- Install sbt 0.11.2.
- Run sbt in the root project directory.
- Use the container:start target to start the service:
bburton$ sbt
> container:start
[info] Started SelectChannelConnector@0.0.0.0:8080 STARTING
[success] Total time: 10 s, completed Apr 7, 2012 9:20:31 AM
- Install the Scala and sbt plugins.
- Use the sbt-idea sbt plugin target to generate the project files:
bburton$ sbt
> gen-idea
[info] Trying to create an Idea module default-eb8248
[info] Excluding folder target
[info] Created /Users/bburton/Documents/workspace-scala/goose-log/.idea/goose-log.iml
[info] Created /Users/bburton/Documents/workspace-scala/goose-log/.idea
[info] Excluding folder /Users/bburton/Documents/workspace-scala/goose-log/target
[info] Created /Users/bburton/Documents/workspace-scala/goose-log/.idea_modules/default-eb8248.iml
[info] Created /Users/bburton/Documents/workspace-scala/goose-log/.idea_modules/project.iml
- Launch IntelliJ IDEA and select File > Open Project, choosing the goose-log folder as the project root.
You can use the client-side logger provided here: TODO -- add JS code for frontend
goose-log processes JSON requests of the following format:
{
"details" : {
"event" : "inbox.message.read",
"message" : "inbox message not found exception"
}
}
It expects a top-level key of "details" which can contain an arbitrary JSON object rendered in the server logs as:
> ERROR [2012-04-07 20:38:01,666] com.goose.logging.ErrorLoggingServlet:
User Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.27) Gecko/20120216 Firefox/3.6.27
Origin: http://fiddle.jshell.net
Timestamp: Sat Apr 07 16:38:01 EDT 2012
Details:
event: inbox.message.read
message: inbox message not found exception
Any of the additional metadata parameters (User Agent, Origin, Timestamp) can be explicitly overridden in the JSON request (TODO this isn't actually true at the moment):
{
"userAgent" : "Lynx/2.8.5dev.16 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6b",
"origin" : "http://www.google.com/",
"timestamp" : 978310861000,
"details" : {
"event" : "inbox.message.read",
"message" : "inbox message not found exception"
}
}
generates the corresponding log entry:
> ERROR [2012-04-07 20:38:01,666] com.goose.logging.ErrorLoggingServlet:
User Agent: Lynx/2.8.5dev.16 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6b
Origin: http://www.google.com/
Timestamp: Sun Dec 31 20:01:01 EST 2000
Details:
event: inbox.message.read
message: inbox message not found exception
Note that the timestamp JSON will accept a Long value representing milliseconds since the Unix epoc, or a string representing a timestamp to be written to the log explicitly.
You can add a provider. It writes to a files with that name. (TODO: rewrite this copy)
For example, the JSON request
{
"provider" : "my-awesome-webapp",
"details" : {
"event" : "inbox.message.read",
"message" : "inbox message not found exception"
}
}
will append to the file my-awesome-webapp.log in the default directory (currently /var/log/).
Instead of passing error logging requests one-at-a-time, the logger can accept a JSON list of objects:
[{
"details" : {
"event" : "inbox.message.read",
"message" : "inbox message not found exception"
}
},{
"details" : {
"event" : "user.authentication",
"message" : "bad user authentication information"
}
}]