bc9bf6355665378f415487f139baeb615057a0a4.svn-base
7 KB
<!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 … <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">¶</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">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="p">{</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">"Input must be constructed with at least basic details."</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>
<span class="p">};</span>
<span class="nx">Input</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">msg</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">this</span><span class="p">.</span><span class="nx">client</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">input_token</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="nx">Input</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">address</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">client</span><span class="p">.</span><span class="nx">addDeviceToInput</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">id</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>
</pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">¶</a> </div> <p>Sets the properties for this instance
Parameters: details</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Input</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_setProperties</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">details</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">¶</a> </div> <p>Copy the properties to this instance</p> </td> <td class="code"> <div class="highlight"><pre> <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="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">details</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">key</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">self</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">details</span><span class="p">[</span><span class="nx">key</span><span class="p">];</span>
<span class="p">});</span>
<span class="p">};</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>