17a26e85558166557e9cf368f1c34cfd7cbaac04.svn-base 30.4 KB
<!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>
<span class="cm"> * MIT LICENSE</span>
<span class="cm"> *</span>
<span class="cm"> */</span>

<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">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)
  Creates a new instance of a Loggly client.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nx">exports</span><span class="p">.</span><span class="nx">createClient</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">return</span> <span class="k">new</span> <span class="nx">Loggly</span><span class="p">(</span><span class="nx">config</span><span class="p">.</span><span class="nx">createConfig</span><span class="p">(</span><span class="nx">options</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>Loggly (config)
  Constructor for the Loggly object</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="kd">var</span> <span class="nx">Loggly</span> <span class="o">=</span> <span class="nx">exports</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="nx">config</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">this</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>                               <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="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="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">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="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="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> 
  
  <span class="k">return</span> <span class="nx">emitter</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>function search (query, callback)
  Returns a new search object which can be chained
  with options or called directly if @callback is passed
  initially.</p>

<p>Sample Usage:</p>

<p>client.search('404')
        .meta({ ip: '127.0.0.1' })
        .context({ rows: 100 })
        .run(function () { /* ... */ });</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">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">callback</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">return</span> <span class="k">new</span> <span class="nx">Search</span><span class="p">(</span><span class="nx">query</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="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>function facet (facet, query, [options], callback) 
  Performs a facet search against loggly with the 
  specified facet, query and options.</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">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">callback</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">return</span> <span class="k">new</span> <span class="nx">Facet</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="k">this</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-7">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-7">&#182;</a>               </div>               <p>function getInputs ([raw], callback) 
  Returns a list of all inputs 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">getInputs</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">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">,</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">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">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>
      <span class="p">});</span>
      
      <span class="k">return</span> <span class="nx">callback</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">inputs</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">results</span><span class="p">);</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>function getInput (name, callback)
  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="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">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>
<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 addDevice (inputId, address, callback) 
  Adds the device at address to the input specified by inputId</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">addDeviceToInput</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">address</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">addOptions</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">logglyUrl</span><span class="p">(</span><span class="s1">&#39;devices&#39;</span><span class="p">),</span>
    <span class="nx">auth</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">auth</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">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;application/x-www-form-urlencoded&#39;</span>
    <span class="p">},</span>
    <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">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>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">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>
    
    <span class="nx">callback</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">devices</span><span class="p">);</span>
  <span class="p">});</span>
<span class="p">};</span></pre></div>             </td>           </tr>                               <tr id="section-14">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-14">&#182;</a>               </div>               <p>function logglyUrl ([path, to, resource])
  Helper method that concats the string params into a url
  to request against a loggly serverUrl. </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">logglyUrl</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="cm">/* path, to, resource */</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="k">return</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">logglyUrl</span><span class="p">].</span><span class="nx">concat</span><span class="p">(</span><span class="nx">args</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="p">};</span>

</pre></div>             </td>           </tr>                </tbody>     </table>   </div> </body> </html>