Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[doc] Updated docco docs

  • Loading branch information...
commit f582c3af55938d32ead905e40666065e22b40e59 1 parent 4bd1104
Charlie Robbins indexzero authored
8 docs/loggly.html
View
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <html> <head> <title>loggly.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="loggly/config.html"> loggly/config.html </a> <a class="source" href="loggly/core.html"> loggly/core.html </a> <a class="source" href="loggly/device.html"> loggly/device.html </a> <a class="source" href="loggly/facet.html"> loggly/facet.html </a> <a class="source" href="loggly/input.html"> loggly/input.html </a> <a class="source" href="loggly/interns.html"> loggly/interns.html </a> <a class="source" href="loggly/search.html"> loggly/search.html </a> <a class="source" href="loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> loggly.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<!DOCTYPE html> <html> <head> <title>loggly.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="loggly/common.html"> loggly/common.html </a> <a class="source" href="loggly/config.html"> loggly/config.html </a> <a class="source" href="loggly/core.html"> loggly/core.html </a> <a class="source" href="loggly/device.html"> loggly/device.html </a> <a class="source" href="loggly/facet.html"> loggly/facet.html </a> <a class="source" href="loggly/input.html"> loggly/input.html </a> <a class="source" href="loggly/search.html"> loggly/search.html </a> <a class="source" href="loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> loggly.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
<span class="cm"> * loggly.js: Wrapper for node-loggly object</span>
<span class="cm"> *</span>
<span class="cm"> * (C) 2010 Nodejitsu Inc.</span>
@@ -8,7 +8,9 @@
<span class="kd">var</span> <span class="nx">loggly</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Export node-loggly core client APIs</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">loggly</span><span class="p">.</span><span class="nx">createClient</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./loggly/core&#39;</span><span class="p">).</span><span class="nx">createClient</span><span class="p">;</span>
<span class="nx">loggly</span><span class="p">.</span><span class="nx">Loggly</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./loggly/core&#39;</span><span class="p">).</span><span class="nx">Loggly</span><span class="p">;</span>
-<span class="nx">loggly</span><span class="p">.</span><span class="nx">Config</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./loggly/config&#39;</span><span class="p">).</span><span class="nx">Config</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Export Resources for node-loggly</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">loggly</span><span class="p">.</span><span class="nx">Input</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./loggly/input&#39;</span><span class="p">).</span><span class="nx">Input</span><span class="p">;</span>
-<span class="nx">loggly</span><span class="p">.</span><span class="nx">Device</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./loggly/device&#39;</span><span class="p">).</span><span class="nx">Device</span><span class="p">;</span>
+<span class="nx">loggly</span><span class="p">.</span><span class="nx">Config</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./loggly/config&#39;</span><span class="p">).</span><span class="nx">Config</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Export Resources for node-loggly</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">loggly</span><span class="p">.</span><span class="nx">Input</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./loggly/input&#39;</span><span class="p">).</span><span class="nx">Input</span><span class="p">;</span>
+<span class="nx">loggly</span><span class="p">.</span><span class="nx">Facet</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./loggly/facet&#39;</span><span class="p">).</span><span class="nx">Facet</span><span class="p">;</span>
+<span class="nx">loggly</span><span class="p">.</span><span class="nx">Device</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./loggly/device&#39;</span><span class="p">).</span><span class="nx">Device</span><span class="p">;</span>
+<span class="nx">loggly</span><span class="p">.</span><span class="nx">Search</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./loggly/search&#39;</span><span class="p">).</span><span class="nx">Search</span><span class="p">;</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
126 docs/loggly/common.html
View
@@ -0,0 +1,126 @@
+<!DOCTYPE html> <html> <head> <title>common.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/common.html"> loggly/common.html </a> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> common.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * common.js: Common utility functions for requesting against Loggly APIs</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010 Nodejitsu Inc.</span>
+<span class="cm"> * MIT LICENSE</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">request</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;request&#39;</span><span class="p">),</span>
+ <span class="nx">loggly</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../loggly&#39;</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">common</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Failure HTTP Response codes based
+off Loggly specification.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">failCodes</span> <span class="o">=</span> <span class="nx">common</span><span class="p">.</span><span class="nx">failCodes</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="mi">400</span><span class="o">:</span> <span class="s2">&quot;Bad Request&quot;</span><span class="p">,</span>
+ <span class="mi">401</span><span class="o">:</span> <span class="s2">&quot;Unauthorized&quot;</span><span class="p">,</span>
+ <span class="mi">403</span><span class="o">:</span> <span class="s2">&quot;Forbidden&quot;</span><span class="p">,</span>
+ <span class="mi">404</span><span class="o">:</span> <span class="s2">&quot;Not Found&quot;</span><span class="p">,</span>
+ <span class="mi">409</span><span class="o">:</span> <span class="s2">&quot;Conflict / Duplicate&quot;</span><span class="p">,</span>
+ <span class="mi">410</span><span class="o">:</span> <span class="s2">&quot;Gone&quot;</span><span class="p">,</span>
+ <span class="mi">500</span><span class="o">:</span> <span class="s2">&quot;Internal Server Error&quot;</span><span class="p">,</span>
+ <span class="mi">501</span><span class="o">:</span> <span class="s2">&quot;Not Implemented&quot;</span><span class="p">,</span>
+ <span class="mi">503</span><span class="o">:</span> <span class="s2">&quot;Throttled&quot;</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Success HTTP Response codes based
+off Loggly specification.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">successCodes</span> <span class="o">=</span> <span class="nx">common</span><span class="p">.</span><span class="nx">successCodes</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="mi">200</span><span class="o">:</span> <span class="s2">&quot;OK&quot;</span><span class="p">,</span>
+ <span class="mi">201</span><span class="o">:</span> <span class="s2">&quot;Created&quot;</span><span class="p">,</span>
+ <span class="mi">202</span><span class="o">:</span> <span class="s2">&quot;Accepted&quot;</span><span class="p">,</span>
+ <span class="mi">203</span><span class="o">:</span> <span class="s2">&quot;Non-authoritative information&quot;</span><span class="p">,</span>
+ <span class="mi">204</span><span class="o">:</span> <span class="s2">&quot;Deleted&quot;</span><span class="p">,</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Core method that actually sends requests to Loggly.
+This method is designed to be flexible w.r.t. arguments
+and continuation passing given the wide range of different
+requests required to fully implement the Loggly API.</p>
+
+<p>Continuations:
+ 1. 'callback': The callback passed into every node-loggly method
+ 2. 'success': A callback that will only be called on successful requests.
+ This is used throughout node-loggly to conditionally
+ do post-request processing such as JSON parsing.</p>
+
+<p>Possible Arguments (1 &amp; 2 are equivalent):
+ 1. common.loggly('some-fully-qualified-url', auth, callback, success)
+ 2. common.loggly('GET', 'some-fully-qualified-url', auth, callback, success)
+ 3. common.loggly('DELETE', 'some-fully-qualified-url', auth, callback, success)
+ 4. common.loggly({ method: 'POST', uri: 'some-url', body: { some: 'body'} }, callback, success)</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">common</span><span class="p">.</span><span class="nx">loggly</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="nb">Array</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">arguments</span><span class="p">),</span>
+ <span class="nx">success</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">pop</span><span class="p">(),</span>
+ <span class="nx">callback</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">pop</span><span class="p">(),</span>
+ <span class="nx">requestBody</span><span class="p">,</span>
+ <span class="nx">headers</span><span class="p">,</span>
+ <span class="nx">method</span><span class="p">,</span>
+ <span class="nx">auth</span><span class="p">,</span>
+ <span class="nx">uri</span><span class="p">;</span>
+ </pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Now that we've popped off the two callbacks
+We can make decisions about other arguments</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">args</span><span class="p">.</span><span class="nx">length</span> <span class="o">==</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>If we got a string assume that it's the URI </p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">method</span> <span class="o">=</span> <span class="s1">&#39;GET&#39;</span><span class="p">;</span>
+ <span class="nx">uri</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
+ <span class="p">}</span>
+ <span class="k">else</span> <span class="p">{</span>
+ <span class="nx">method</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;method&#39;</span><span class="p">]</span> <span class="o">||</span> <span class="s1">&#39;GET&#39;</span><span class="p">,</span>
+ <span class="nx">uri</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;uri&#39;</span><span class="p">];</span>
+ <span class="nx">requestBody</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;body&#39;</span><span class="p">];</span>
+ <span class="nx">auth</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;auth&#39;</span><span class="p">];</span>
+ <span class="nx">headers</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;headers&#39;</span><span class="p">];</span>
+ <span class="p">}</span>
+ <span class="p">}</span>
+ <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">args</span><span class="p">.</span><span class="nx">length</span> <span class="o">==</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">method</span> <span class="o">=</span> <span class="s1">&#39;GET&#39;</span><span class="p">;</span>
+ <span class="nx">uri</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
+ <span class="nx">auth</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
+ <span class="p">}</span>
+ <span class="k">else</span> <span class="p">{</span>
+ <span class="nx">method</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
+ <span class="nx">uri</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
+ <span class="nx">auth</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
+ <span class="p">}</span>
+
+ <span class="kd">function</span> <span class="nx">onError</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">);</span>
+ <span class="p">}</span>
+ <span class="p">}</span>
+
+ <span class="kd">var</span> <span class="nx">requestOptions</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="nx">uri</span><span class="o">:</span> <span class="nx">uri</span><span class="p">,</span>
+ <span class="nx">method</span><span class="o">:</span> <span class="nx">method</span><span class="p">,</span>
+ <span class="nx">headers</span><span class="o">:</span> <span class="nx">headers</span> <span class="o">||</span> <span class="p">{}</span>
+ <span class="p">};</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">auth</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">requestOptions</span><span class="p">.</span><span class="nx">headers</span><span class="p">[</span><span class="s1">&#39;authorization&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;Basic &#39;</span> <span class="o">+</span> <span class="k">new</span> <span class="nx">Buffer</span><span class="p">(</span><span class="nx">auth</span><span class="p">.</span><span class="nx">username</span> <span class="o">+</span> <span class="s1">&#39;:&#39;</span> <span class="o">+</span> <span class="nx">auth</span><span class="p">.</span><span class="nx">password</span><span class="p">).</span><span class="nx">toString</span><span class="p">(</span><span class="s1">&#39;base64&#39;</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">requestBody</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">requestOptions</span><span class="p">.</span><span class="nx">body</span> <span class="o">=</span> <span class="nx">requestBody</span><span class="p">;</span>
+ <span class="p">}</span>
+
+ <span class="k">try</span> <span class="p">{</span>
+ <span class="nx">request</span><span class="p">(</span><span class="nx">requestOptions</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">onError</span><span class="p">(</span><span class="nx">err</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="kd">var</span> <span class="nx">statusCode</span> <span class="o">=</span> <span class="nx">res</span><span class="p">.</span><span class="nx">statusCode</span><span class="p">.</span><span class="nx">toString</span><span class="p">();</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">failCodes</span><span class="p">).</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">statusCode</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">onError</span><span class="p">((</span><span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Loggly Error (&#39;</span> <span class="o">+</span> <span class="nx">statusCode</span> <span class="o">+</span> <span class="s1">&#39;): &#39;</span> <span class="o">+</span> <span class="nx">failCodes</span><span class="p">[</span><span class="nx">statusCode</span><span class="p">])));</span>
+ <span class="p">}</span>
+
+ <span class="nx">success</span><span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">);</span>
+ <span class="p">});</span>
+ <span class="p">}</span>
+ <span class="k">catch</span> <span class="p">(</span><span class="nx">ex</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">onError</span><span class="p">(</span><span class="nx">ex</span><span class="p">);</span>
+ <span class="p">}</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>function clone (obj)
+ Helper method for deep cloning pure JSON objects
+ i.e. JSON objects that are either literals or objects (no Arrays, etc)</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">common</span><span class="p">.</span><span class="nx">clone</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">clone</span> <span class="o">=</span> <span class="p">{};</span>
+ <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">obj</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">clone</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">obj</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="k">instanceof</span> <span class="nb">Object</span> <span class="o">?</span> <span class="nx">common</span><span class="p">.</span><span class="nx">clone</span><span class="p">(</span><span class="nx">obj</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span> <span class="o">:</span> <span class="nx">obj</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
+ <span class="p">}</span>
+
+ <span class="k">return</span> <span class="nx">clone</span><span class="p">;</span>
+<span class="p">};</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
13 docs/loggly/config.html
View
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <html> <head> <title>config.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/interns.html"> loggly/interns.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> config.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<!DOCTYPE html> <html> <head> <title>config.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/common.html"> loggly/common.html </a> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> config.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
<span class="cm"> * config.js: Configuration information for your Loggly account.</span>
<span class="cm"> * This information is only used for require(&#39;loggly&#39;)./\.+/ methods</span>
<span class="cm"> *</span>
@@ -10,10 +10,13 @@
object based on default values</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">exports</span><span class="p">.</span><span class="nx">createConfig</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">defaults</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">new</span> <span class="nx">Config</span><span class="p">(</span><span class="nx">defaults</span><span class="p">);</span>
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Config (defaults)
- Constructor for the Config object</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">Config</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">defaults</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">defaults</span><span class="p">.</span><span class="nx">subdomain</span><span class="p">)</span> <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Subdomain is required to create an instance of Config&#39;</span><span class="p">);</span>
+ Constructor for the Config object</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">Config</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Config</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">defaults</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">defaults</span><span class="p">.</span><span class="nx">subdomain</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Subdomain is required to create an instance of Config&#39;</span><span class="p">);</span>
+ <span class="p">}</span>
<span class="k">this</span><span class="p">.</span><span class="nx">subdomain</span> <span class="o">=</span> <span class="nx">defaults</span><span class="p">.</span><span class="nx">subdomain</span><span class="p">;</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">json</span> <span class="o">=</span> <span class="nx">defaults</span><span class="p">.</span><span class="nx">json</span> <span class="o">||</span><span class="err"> </span><span class="kc">null</span><span class="p">;</span>
<span class="k">this</span><span class="p">.</span><span class="nx">auth</span> <span class="o">=</span> <span class="nx">defaults</span><span class="p">.</span><span class="nx">auth</span> <span class="o">||</span> <span class="kc">null</span><span class="p">;</span>
<span class="p">};</span>
@@ -21,7 +24,7 @@
<span class="nx">get</span> <span class="nx">subdomain</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_subdomain</span><span class="p">;</span>
<span class="p">},</span>
-
+
<span class="nx">set</span> <span class="nx">subdomain</span> <span class="p">(</span><span class="nx">value</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_subdomain</span> <span class="o">=</span> <span class="nx">value</span><span class="p">;</span>
<span class="p">},</span>
@@ -33,6 +36,6 @@
<span class="nx">get</span> <span class="nx">inputUrl</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="s1">&#39;https://logs.loggly.com/inputs/&#39;</span><span class="p">;</span>
<span class="p">}</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Export the Config object</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">exports</span><span class="p">.</span><span class="nx">Config</span> <span class="o">=</span> <span class="nx">Config</span><span class="p">;</span>
+<span class="p">};</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
55 docs/loggly/core.html
View
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <html> <head> <title>core.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/interns.html"> loggly/interns.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> core.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<!DOCTYPE html> <html> <head> <title>core.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/common.html"> loggly/common.html </a> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> core.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
<span class="cm"> * core.js: Core functions for accessing Loggly</span>
<span class="cm"> *</span>
<span class="cm"> * (C) 2010 Nodejitsu Inc.</span>
@@ -9,7 +9,7 @@
<span class="kd">var</span> <span class="nx">events</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;events&#39;</span><span class="p">),</span>
<span class="nx">qs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;querystring&#39;</span><span class="p">),</span>
<span class="nx">config</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./config&#39;</span><span class="p">),</span>
- <span class="nx">interns</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./interns&#39;</span><span class="p">),</span>
+ <span class="nx">common</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./common&#39;</span><span class="p">),</span>
<span class="nx">Search</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./search&#39;</span><span class="p">).</span><span class="nx">Search</span><span class="p">,</span>
<span class="nx">Facet</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./facet&#39;</span><span class="p">).</span><span class="nx">Facet</span><span class="p">,</span>
<span class="nx">loggly</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../loggly&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>function createClient (options)
@@ -21,25 +21,36 @@
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>function log (callback)
logs args to input device</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Loggly</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">log</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">inputId</span><span class="p">,</span> <span class="nx">msg</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">emitter</span> <span class="o">=</span> <span class="k">new</span> <span class="p">(</span><span class="nx">events</span><span class="p">.</span><span class="nx">EventEmitter</span><span class="p">)(),</span>
- <span class="nx">message</span> <span class="o">=</span> <span class="nx">msg</span> <span class="k">instanceof</span> <span class="nb">Object</span> <span class="o">?</span> <span class="nx">qs</span><span class="p">.</span><span class="nx">unescape</span><span class="p">(</span><span class="nx">qs</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">msg</span><span class="p">,</span> <span class="s1">&#39;,&#39;</span><span class="p">))</span> <span class="o">:</span> <span class="nx">msg</span><span class="p">;</span>
+ <span class="nx">message</span><span class="p">;</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">msg</span> <span class="k">instanceof</span> <span class="nb">Object</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">message</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">json</span> <span class="o">?</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">msg</span><span class="p">)</span> <span class="o">:</span> <span class="nx">qs</span><span class="p">.</span><span class="nx">unescape</span><span class="p">(</span><span class="nx">qs</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">msg</span><span class="p">,</span> <span class="s1">&#39;,&#39;</span><span class="p">));</span>
+ <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+ <span class="nx">message</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">json</span> <span class="o">?</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">({</span> <span class="nx">message</span> <span class="o">:</span> <span class="nx">msg</span> <span class="p">})</span> <span class="o">:</span> <span class="nx">msg</span><span class="p">;</span>
+ <span class="p">}</span>
<span class="kd">var</span> <span class="nx">logOptions</span> <span class="o">=</span> <span class="p">{</span>
<span class="nx">uri</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">inputUrl</span> <span class="o">+</span> <span class="nx">inputId</span><span class="p">,</span>
<span class="nx">method</span><span class="o">:</span> <span class="s1">&#39;POST&#39;</span><span class="p">,</span>
<span class="nx">body</span><span class="o">:</span> <span class="nx">message</span><span class="p">,</span>
<span class="nx">headers</span><span class="o">:</span> <span class="p">{</span>
- <span class="s1">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="s1">&#39;text/plain&#39;</span>
+ <span class="s1">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">json</span> <span class="o">?</span> <span class="s1">&#39;application/json&#39;</span> <span class="o">:</span> <span class="s1">&#39;text/plain&#39;</span>
<span class="p">}</span>
<span class="p">};</span>
-
- <span class="nx">interns</span><span class="p">.</span><span class="nx">loggly</span><span class="p">(</span><span class="nx">logOptions</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+
+ <span class="nx">common</span><span class="p">.</span><span class="nx">loggly</span><span class="p">(</span><span class="nx">logOptions</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
<span class="k">try</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">body</span><span class="p">);</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="nx">callback</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">result</span><span class="p">);</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">callback</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">result</span><span class="p">);</span>
+ <span class="p">}</span>
+
<span class="nx">emitter</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;log&#39;</span><span class="p">,</span> <span class="nx">result</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">catch</span> <span class="p">(</span><span class="nx">ex</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="nx">callback</span><span class="p">(</span><span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Unspecified error from Loggly: &#39;</span> <span class="o">+</span> <span class="nx">ex</span><span class="p">));</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">callback</span><span class="p">(</span><span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Unspecified error from Loggly: &#39;</span> <span class="o">+</span> <span class="nx">ex</span><span class="p">));</span>
+ <span class="p">}</span>
<span class="p">}</span>
<span class="p">});</span>
@@ -67,8 +78,10 @@
<span class="nx">callback</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">pop</span><span class="p">(),</span>
<span class="nx">raw</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="o">?</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">:</span> <span class="kc">false</span><span class="p">;</span>
- <span class="nx">interns</span><span class="p">.</span><span class="nx">loggly</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">logglyUrl</span><span class="p">(</span><span class="s1">&#39;inputs&#39;</span><span class="p">),</span> <span class="k">this</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">auth</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">inputs</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">results</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">body</span><span class="p">);</span>
+ <span class="nx">common</span><span class="p">.</span><span class="nx">loggly</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">logglyUrl</span><span class="p">(</span><span class="s1">&#39;inputs&#39;</span><span class="p">),</span> <span class="k">this</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">auth</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">inputs</span> <span class="o">=</span> <span class="p">[],</span>
+ <span class="nx">results</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">body</span><span class="p">);</span>
+
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">raw</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">results</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">result</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">inputs</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="k">new</span> <span class="p">(</span><span class="nx">loggly</span><span class="p">.</span><span class="nx">Input</span><span class="p">)(</span><span class="nx">self</span><span class="p">,</span> <span class="nx">result</span><span class="p">));</span>
@@ -83,10 +96,16 @@
Returns the input with the specified name </p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Loggly</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">getInput</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
<span class="k">this</span><span class="p">.</span><span class="nx">getInputs</span><span class="p">(</span><span class="kc">true</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">results</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">);</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">);</span>
+ <span class="p">}</span>
- <span class="kd">var</span> <span class="nx">input</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">matches</span> <span class="o">=</span> <span class="nx">results</span><span class="p">.</span><span class="nx">filter</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">r</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">r</span><span class="p">.</span><span class="nx">name</span> <span class="o">===</span> <span class="nx">name</span> <span class="p">});</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">matches</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="nx">input</span> <span class="o">=</span> <span class="k">new</span> <span class="p">(</span><span class="nx">loggly</span><span class="p">.</span><span class="nx">Input</span><span class="p">)(</span><span class="nx">self</span><span class="p">,</span> <span class="nx">matches</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span>
+ <span class="kd">var</span> <span class="nx">matches</span> <span class="o">=</span> <span class="nx">results</span><span class="p">.</span><span class="nx">filter</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">r</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">r</span><span class="p">.</span><span class="nx">name</span> <span class="o">===</span> <span class="nx">name</span> <span class="p">}),</span>
+ <span class="nx">input</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">matches</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">input</span> <span class="o">=</span> <span class="k">new</span> <span class="p">(</span><span class="nx">loggly</span><span class="p">.</span><span class="nx">Input</span><span class="p">)(</span><span class="nx">self</span><span class="p">,</span> <span class="nx">matches</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span>
+ <span class="p">}</span>
<span class="nx">callback</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">input</span><span class="p">);</span>
<span class="p">});</span>
@@ -102,17 +121,19 @@
<span class="nx">body</span><span class="o">:</span> <span class="nx">qs</span><span class="p">.</span><span class="nx">stringify</span><span class="p">({</span> <span class="s1">&#39;input_id&#39;</span><span class="o">:</span> <span class="nx">inputId</span><span class="p">,</span> <span class="s1">&#39;ip&#39;</span><span class="o">:</span> <span class="nx">address</span> <span class="p">}).</span><span class="nx">replace</span><span class="p">(</span><span class="s1">&#39;&quot;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
<span class="p">};</span>
- <span class="nx">interns</span><span class="p">.</span><span class="nx">loggly</span><span class="p">(</span><span class="nx">addOptions</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">common</span><span class="p">.</span><span class="nx">loggly</span><span class="p">(</span><span class="nx">addOptions</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">callback</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">res</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>function addDevice (inputId, callback)
Adds the calling device to the input</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Loggly</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">addDevice</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">inputId</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>Remark: This is not fully implemented yet</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">callback</span><span class="p">(</span><span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Not Implemented Yet...&#39;</span><span class="p">));</span>
- </pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>interns.loggly(this.logglyUrl('inputs', inputId, 'adddevice'), this.config.auth, callback, function (res, body) {
+ </pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>common.loggly(this.logglyUrl('inputs', inputId, 'adddevice'), this.config.auth, callback, function (res, body) {
});</p> </td> <td class="code"> <div class="highlight"><pre><span class="p">};</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <p>function getDevices (callback)
Returns a list of all devices for the authenicated account</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Loggly</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">getDevices</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
- <span class="nx">interns</span><span class="p">.</span><span class="nx">loggly</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">logglyUrl</span><span class="p">(</span><span class="s1">&#39;devices&#39;</span><span class="p">),</span> <span class="k">this</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">auth</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">devices</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">results</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">body</span><span class="p">);</span>
+ <span class="nx">common</span><span class="p">.</span><span class="nx">loggly</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">logglyUrl</span><span class="p">(</span><span class="s1">&#39;devices&#39;</span><span class="p">),</span> <span class="k">this</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">auth</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">results</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">body</span><span class="p">),</span>
+ <span class="nx">devices</span> <span class="o">=</span> <span class="p">[];</span>
+
<span class="nx">results</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">result</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">devices</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="k">new</span> <span class="p">(</span><span class="nx">loggly</span><span class="p">.</span><span class="nx">Device</span><span class="p">)(</span><span class="nx">self</span><span class="p">,</span> <span class="nx">result</span><span class="p">));</span>
<span class="p">});</span>
5 docs/loggly/device.html
View
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <html> <head> <title>device.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/interns.html"> loggly/interns.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> device.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<!DOCTYPE html> <html> <head> <title>device.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/common.html"> loggly/common.html </a> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> device.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
<span class="cm"> * device.js: Instance of a single Loggly device</span>
<span class="cm"> *</span>
<span class="cm"> * (C) 2010 Nodejitsu Inc.</span>
@@ -6,9 +6,6 @@
<span class="cm"> *</span>
<span class="cm"> */</span>
-<span class="kd">var</span> <span class="nx">loggly</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../loggly&#39;</span><span class="p">),</span>
- <span class="nx">interns</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./interns&#39;</span><span class="p">);</span>
-
<span class="kd">var</span> <span class="nx">Device</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Device</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">client</span><span class="p">,</span> <span class="nx">details</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">details</span><span class="p">)</span> <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">&quot;Device must be constructed with at least basic details.&quot;</span><span class="p">)</span>
10 docs/loggly/facet.html
View
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <html> <head> <title>facet.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/interns.html"> loggly/interns.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> facet.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<!DOCTYPE html> <html> <head> <title>facet.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/common.html"> loggly/common.html </a> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> facet.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
<span class="cm"> * facet.js: Chainable search functions for Loggly facet searches.</span>
<span class="cm"> *</span>
<span class="cm"> * (C) 2010 Nodejitsu Inc.</span>
@@ -11,6 +11,7 @@
Chainable facet search object for Loggly API</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">Facet</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Facet</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">facet</span><span class="p">,</span> <span class="nx">query</span><span class="p">,</span> <span class="nx">client</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">([</span><span class="s1">&#39;date&#39;</span><span class="p">,</span> <span class="s1">&#39;ip&#39;</span><span class="p">,</span> <span class="s1">&#39;input&#39;</span><span class="p">].</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">facet</span><span class="p">)</span> <span class="o">===</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">error</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Cannot search with unknown facet: &#39;</span> <span class="o">+</span> <span class="nx">facet</span><span class="p">);</span>
+
<span class="k">if</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">error</span><span class="p">);</span>
<span class="p">}</span>
@@ -19,10 +20,7 @@
<span class="p">}</span>
<span class="p">}</span>
</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Set the baseUrl to be facet/:facet?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">this</span><span class="p">.</span><span class="nx">baseUrl</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;facets&#39;</span><span class="p">,</span> <span class="nx">facet</span> <span class="o">+</span> <span class="s1">&#39;?&#39;</span><span class="p">].</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">);</span>
-
- <span class="nx">Search</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">query</span><span class="p">,</span> <span class="nx">client</span><span class="p">,</span> <span class="nx">callback</span><span class="p">);</span>
-<span class="p">};</span>
-
-<span class="nx">util</span><span class="p">.</span><span class="nx">inherits</span><span class="p">(</span><span class="nx">Facet</span><span class="p">,</span> <span class="nx">Search</span><span class="p">);</span>
+ </pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Call the base constructor.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">Search</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">query</span><span class="p">,</span> <span class="nx">client</span><span class="p">,</span> <span class="nx">callback</span><span class="p">);</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Inherit from <code>loggly.Search</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">util</span><span class="p">.</span><span class="nx">inherits</span><span class="p">(</span><span class="nx">Facet</span><span class="p">,</span> <span class="nx">Search</span><span class="p">);</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
9 docs/loggly/input.html
View
@@ -1,16 +1,15 @@
-<!DOCTYPE html> <html> <head> <title>input.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/interns.html"> loggly/interns.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> input.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<!DOCTYPE html> <html> <head> <title>input.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/common.html"> loggly/common.html </a> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> input.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
<span class="cm"> * input.js: Instance of a single Loggly input</span>
<span class="cm"> *</span>
<span class="cm"> * (C) 2010 Nodejitsu Inc.</span>
<span class="cm"> * MIT LICENSE</span>
<span class="cm"> *</span>
<span class="cm"> */</span>
-
-<span class="kd">var</span> <span class="nx">loggly</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../loggly&#39;</span><span class="p">),</span>
- <span class="nx">interns</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./interns&#39;</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">Input</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Input</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">client</span><span class="p">,</span> <span class="nx">details</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">details</span><span class="p">)</span> <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">&quot;Input must be constructed with at least basic details.&quot;</span><span class="p">);</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">details</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">&quot;Input must be constructed with at least basic details.&quot;</span><span class="p">);</span>
+ <span class="p">}</span>
<span class="k">this</span><span class="p">.</span><span class="nx">client</span> <span class="o">=</span> <span class="nx">client</span><span class="p">;</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_setProperties</span><span class="p">(</span><span class="nx">details</span><span class="p">);</span>
120 docs/loggly/interns.html
View
@@ -1,120 +0,0 @@
-<!DOCTYPE html> <html> <head> <title>interns.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/interns.html"> loggly/interns.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> interns.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
-<span class="cm"> * interns.js: Internal utility functions for requesting against Loggly APIs</span>
-<span class="cm"> *</span>
-<span class="cm"> * (C) 2010 Nodejitsu Inc.</span>
-<span class="cm"> * MIT LICENSE</span>
-<span class="cm"> *</span>
-<span class="cm"> */</span>
-
-<span class="kd">var</span> <span class="nx">request</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;request&#39;</span><span class="p">),</span>
- <span class="nx">loggly</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../loggly&#39;</span><span class="p">);</span>
-
-<span class="kd">var</span> <span class="nx">interns</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Failure HTTP Response codes based
-off Loggly specification.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">failCodes</span> <span class="o">=</span> <span class="p">{</span>
- <span class="mi">400</span><span class="o">:</span> <span class="s2">&quot;Bad Request&quot;</span><span class="p">,</span>
- <span class="mi">401</span><span class="o">:</span> <span class="s2">&quot;Unauthorized&quot;</span><span class="p">,</span>
- <span class="mi">403</span><span class="o">:</span> <span class="s2">&quot;Forbidden&quot;</span><span class="p">,</span>
- <span class="mi">404</span><span class="o">:</span> <span class="s2">&quot;Not Found&quot;</span><span class="p">,</span>
- <span class="mi">409</span><span class="o">:</span> <span class="s2">&quot;Conflict / Duplicate&quot;</span><span class="p">,</span>
- <span class="mi">410</span><span class="o">:</span> <span class="s2">&quot;Gone&quot;</span><span class="p">,</span>
- <span class="mi">500</span><span class="o">:</span> <span class="s2">&quot;Internal Server Error&quot;</span><span class="p">,</span>
- <span class="mi">501</span><span class="o">:</span> <span class="s2">&quot;Not Implemented&quot;</span><span class="p">,</span>
- <span class="mi">503</span><span class="o">:</span> <span class="s2">&quot;Throttled&quot;</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Export the set of Failure Codes</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">interns</span><span class="p">.</span><span class="nx">failCodes</span> <span class="o">=</span> <span class="nx">failCodes</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Success HTTP Response codes based
-off Loggly specification.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">successCodes</span> <span class="o">=</span> <span class="p">{</span>
- <span class="mi">200</span><span class="o">:</span> <span class="s2">&quot;OK&quot;</span><span class="p">,</span>
- <span class="mi">201</span><span class="o">:</span> <span class="s2">&quot;Created&quot;</span><span class="p">,</span>
- <span class="mi">202</span><span class="o">:</span> <span class="s2">&quot;Accepted&quot;</span><span class="p">,</span>
- <span class="mi">203</span><span class="o">:</span> <span class="s2">&quot;Non-authoritative information&quot;</span><span class="p">,</span>
- <span class="mi">204</span><span class="o">:</span> <span class="s2">&quot;Deleted&quot;</span><span class="p">,</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Export the set of Success Codes</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">interns</span><span class="p">.</span><span class="nx">successCodes</span> <span class="o">=</span> <span class="nx">successCodes</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Core method that actually sends requests to Loggly.
-This method is designed to be flexible w.r.t. arguments
-and continuation passing given the wide range of different
-requests required to fully implement the Loggly API.</p>
-
-<p>Continuations:
- 1. 'callback': The callback passed into every node-loggly method
- 2. 'success': A callback that will only be called on successful requests.
- This is used throughout node-loggly to conditionally
- do post-request processing such as JSON parsing.</p>
-
-<p>Possible Arguments (1 &amp; 2 are equivalent):
- 1. interns.loggly('some-fully-qualified-url', auth, callback, success)
- 2. interns.loggly('GET', 'some-fully-qualified-url', auth, callback, success)
- 3. interns.loggly('DELETE', 'some-fully-qualified-url', auth, callback, success)
- 4. interns.loggly({ method: 'POST', uri: 'some-url', body: { some: 'body'} }, callback, success)</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">interns</span><span class="p">.</span><span class="nx">loggly</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="nb">Array</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">arguments</span><span class="p">),</span>
- <span class="nx">success</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">pop</span><span class="p">(),</span>
- <span class="nx">callback</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">pop</span><span class="p">(),</span>
- <span class="nx">uri</span><span class="p">,</span> <span class="nx">method</span><span class="p">,</span> <span class="nx">requestBody</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">headers</span><span class="p">;</span>
- </pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Now that we've popped off the two callbacks
-We can make decisions about other arguments</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">args</span><span class="p">.</span><span class="nx">length</span> <span class="o">==</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span><span class="p">(</span><span class="k">typeof</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>If we got a string assume that it's the URI </p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">method</span> <span class="o">=</span> <span class="s1">&#39;GET&#39;</span><span class="p">;</span>
- <span class="nx">uri</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="p">{</span>
- <span class="nx">method</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;method&#39;</span><span class="p">]</span> <span class="o">||</span> <span class="s1">&#39;GET&#39;</span><span class="p">,</span>
- <span class="nx">uri</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;uri&#39;</span><span class="p">];</span>
- <span class="nx">requestBody</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;body&#39;</span><span class="p">];</span>
- <span class="nx">auth</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;auth&#39;</span><span class="p">];</span>
- <span class="nx">headers</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;headers&#39;</span><span class="p">];</span>
- <span class="p">}</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">args</span><span class="p">.</span><span class="nx">length</span> <span class="o">==</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">method</span> <span class="o">=</span> <span class="s1">&#39;GET&#39;</span><span class="p">;</span>
- <span class="nx">uri</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
- <span class="nx">auth</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
- <span class="p">}</span>
- <span class="k">else</span> <span class="p">{</span>
- <span class="nx">method</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
- <span class="nx">uri</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
- <span class="nx">auth</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
- <span class="p">}</span>
-
- <span class="kd">var</span> <span class="nx">requestOptions</span> <span class="o">=</span> <span class="p">{</span>
- <span class="nx">uri</span><span class="o">:</span> <span class="nx">uri</span><span class="p">,</span>
- <span class="nx">method</span><span class="o">:</span> <span class="nx">method</span><span class="p">,</span>
- <span class="nx">headers</span><span class="o">:</span> <span class="nx">headers</span> <span class="o">||</span> <span class="p">{}</span>
- <span class="p">};</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nx">auth</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">requestOptions</span><span class="p">[</span><span class="s1">&#39;headers&#39;</span><span class="p">][</span><span class="s1">&#39;authorization&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;Basic &#39;</span> <span class="o">+</span> <span class="k">new</span> <span class="nx">Buffer</span><span class="p">(</span><span class="nx">auth</span><span class="p">.</span><span class="nx">username</span> <span class="o">+</span> <span class="s1">&#39;:&#39;</span> <span class="o">+</span> <span class="nx">auth</span><span class="p">.</span><span class="nx">password</span><span class="p">).</span><span class="nx">toString</span><span class="p">(</span><span class="s1">&#39;base64&#39;</span><span class="p">);</span>
- <span class="p">}</span>
-
- <span class="k">if</span> <span class="p">(</span><span class="nx">requestBody</span><span class="p">)</span> <span class="nx">requestOptions</span><span class="p">.</span><span class="nx">body</span> <span class="o">=</span> <span class="nx">requestBody</span><span class="p">;</span>
-
- <span class="k">try</span> <span class="p">{</span>
- <span class="nx">request</span><span class="p">(</span><span class="nx">requestOptions</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">callback</span><span class="p">(</span><span class="nx">err</span><span class="p">);</span>
- <span class="p">}</span>
- <span class="k">return</span><span class="p">;</span>
- <span class="p">}</span>
-
- <span class="kd">var</span> <span class="nx">statusCode</span> <span class="o">=</span> <span class="nx">res</span><span class="p">.</span><span class="nx">statusCode</span><span class="p">.</span><span class="nx">toString</span><span class="p">();</span>
- <span class="k">if</span> <span class="p">(</span><span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">failCodes</span><span class="p">).</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">statusCode</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">callback</span><span class="p">(</span><span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Loggly Error (&#39;</span> <span class="o">+</span> <span class="nx">statusCode</span> <span class="o">+</span> <span class="s1">&#39;): &#39;</span> <span class="o">+</span> <span class="nx">failCodes</span><span class="p">[</span><span class="nx">statusCode</span><span class="p">]));</span>
- <span class="p">}</span>
- <span class="k">return</span><span class="p">;</span>
- <span class="p">}</span>
-
- <span class="nx">success</span><span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">);</span>
- <span class="p">});</span>
- <span class="p">}</span>
- <span class="k">catch</span> <span class="p">(</span><span class="nx">ex</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="nx">callback</span><span class="p">(</span><span class="nx">ex</span><span class="p">);</span>
- <span class="p">}</span>
-<span class="p">};</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>function clone (obj)
- Helper method for deep cloning pure JSON objects
- i.e. JSON objects that are either literals or objects (no Arrays, etc)</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">interns</span><span class="p">.</span><span class="nx">clone</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">clone</span> <span class="o">=</span> <span class="p">{};</span>
- <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">obj</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">clone</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">obj</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="k">instanceof</span> <span class="nb">Object</span> <span class="o">?</span> <span class="nx">interns</span><span class="p">.</span><span class="nx">clone</span><span class="p">(</span><span class="nx">obj</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span> <span class="o">:</span> <span class="nx">obj</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
- <span class="p">}</span>
-
- <span class="k">return</span> <span class="nx">clone</span><span class="p">;</span>
-<span class="p">};</span>
-
-</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
7 docs/loggly/search.html
View
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <html> <head> <title>search.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/interns.html"> loggly/interns.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> search.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<!DOCTYPE html> <html> <head> <title>search.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//loggly/common.html"> loggly/common.html </a> <a class="source" href="..//loggly/config.html"> loggly/config.html </a> <a class="source" href="..//loggly/core.html"> loggly/core.html </a> <a class="source" href="..//loggly/device.html"> loggly/device.html </a> <a class="source" href="..//loggly/facet.html"> loggly/facet.html </a> <a class="source" href="..//loggly/input.html"> loggly/input.html </a> <a class="source" href="..//loggly/search.html"> loggly/search.html </a> <a class="source" href="..//loggly.html"> loggly.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> search.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
<span class="cm"> * search.js: chainable search functions for Loggly</span>
<span class="cm"> *</span>
<span class="cm"> * (C) 2010 Nodejitsu Inc.</span>
@@ -8,10 +8,11 @@
<span class="kd">var</span> <span class="nx">qs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;querystring&#39;</span><span class="p">),</span>
<span class="nx">timespan</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;timespan&#39;</span><span class="p">),</span>
- <span class="nx">interns</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./interns&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>function Search (query, client, callback)
+ <span class="nx">common</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./common&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>function Search (query, client, callback)
Chainable search object for Loggly API</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">Search</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Search</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">query</span><span class="p">,</span> <span class="nx">client</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">query</span> <span class="o">=</span> <span class="nx">query</span><span class="p">;</span>
<span class="k">this</span><span class="p">.</span><span class="nx">client</span> <span class="o">=</span> <span class="nx">client</span><span class="p">;</span>
+
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">baseUrl</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">baseUrl</span> <span class="o">=</span> <span class="s1">&#39;search?&#39;</span><span class="p">;</span>
<span class="p">}</span>
@@ -52,7 +53,7 @@
<span class="nx">auth</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">client</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">auth</span>
<span class="p">};</span>
- <span class="nx">interns</span><span class="p">.</span><span class="nx">loggly</span><span class="p">(</span><span class="nx">searchOptions</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">common</span><span class="p">.</span><span class="nx">loggly</span><span class="p">(</span><span class="nx">searchOptions</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">self</span><span class="p">.</span><span class="nx">callback</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">body</span><span class="p">));</span>
<span class="p">});</span>
Please sign in to comment.
Something went wrong with that request. Please try again.