Skip to content
This repository has been archived by the owner. It is now read-only.

Added better example and updated Readme #3

Open
wants to merge 3 commits into
base: master
from
Open
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Updated example

  • Loading branch information
niftylettuce committed Sep 4, 2012
commit cacbc88593ee68d23d02127f5839b0fd6345539f
@@ -2,20 +2,25 @@

JavaScript library to do cross site log POSTing to Loggly. You can use this to log directly out of your JavaScript to Loggly, or just record the fact someone hit a page on your site.

## Live Demo

<http://loggly.github.com/loggly-castor>

## Installation

Include the loggly.js file in a web page. You can use our CloudFront version if you like:

<pre>http://cloudfront.loggly.com/js/loggly-0.1.0.js</pre>
<pre>http://cloudfront.loggly.com/js/loggly-0.2.1.js</pre>

Create a new HTTP input in your Loggly account, make a note of the URL, and then edit and use the following code in that same web page:

```html
<script type="text/javascript">
window.onload=function(){
castor = new loggly({ url: 'http://logs.loggly.com/inputs/a2e232e9-4827-49aa-9d28-e18e5ba5a818?rt=1', level: 'info'});
castor.info("url=" + window.location.href + " browser=" + castor.user_agent + " width=" + castor.browser_size.width);
}
</script>
### Simple Example

```js
window.onload = function() {
castor = new loggly({ url: 'http://logs.loggly.com/inputs/a2e232e9-4827-49aa-9d28-e18e5ba5a818?rt=1', level: 'info'})
castor.info("url=" + window.location.href + " browser=" + castor.user_agent + " width=" + castor.browser_size.width)
}
```

This should result in the page posting an event to Loggly that looks something like this:
@@ -24,5 +29,10 @@ This should result in the page posting an event to Loggly that looks something l
source=castor url=http://www.geekceo.com/ browser=MozillaNetscape5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24 width=1009
```

### Extended Example

See the live demo link above.

## Log Levels

Set the log level using the *level: 'info'* parameter. Call the library using the error, warn, info, debug and log methods. Events called with these methods that match or exceed the current logging level will be forwarded on to Loggly.
@@ -3,16 +3,18 @@
<head>
<title>loggly-castor - Client-side JavaScript Logging Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" href="/images/favicon.ico">
<link rel="stylesheet" href="/css/reset.css" type="text/css" />
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="stylesheet" href="css/reset.css" type="text/css" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<script src="https://raw.github.com/gist/3620903/1dd5b6093046043f9c22d0eac47a616870331f34/getscript.min.js"></script>
</head>
<body>

<div>
<h1>loggly-castor example (<a href="#" id="view-source">view source</a>)</h1>
<p>&copy; 2012 <a href="http://loggly.com/">Loggly, Inc.</a></p>
</div>

<script>

// # loggly-castor example by @niftylettuce
@@ -72,12 +74,9 @@ <h1>loggly-castor example (<a href="#" id="view-source">view source</a>)</h1>
window.onerror = _castor.onerror
}

console.log('_castor', _castor)
console.log('_loggly', _loggly)

getScript(_castor.src, _castor.cb)

</script>

<script>
// example stuff (ignore this)
(function(d, w) {
@@ -89,5 +88,6 @@ <h1>loggly-castor example (<a href="#" id="view-source">view source</a>)</h1>
}
}(document, window))
</script>

</body>
</html>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.