You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

543 lines
17 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>syslog - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package syslog</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "log/syslog"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. </dl>
  58. </div>
  59. <!-- The package's Name is printed as title by the top-level template -->
  60. <div id="pkg-overview" class="toggleVisible">
  61. <div class="collapsed">
  62. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  63. </div>
  64. <div class="expanded">
  65. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  66. <p>
  67. Package syslog provides a simple interface to the system log
  68. service. It can send messages to the syslog daemon using UNIX
  69. domain sockets, UDP or TCP.
  70. </p>
  71. <p>
  72. Only one call to Dial is necessary. On write failures,
  73. the syslog client will attempt to reconnect to the server
  74. and write again.
  75. </p>
  76. <p>
  77. The syslog package is frozen and not accepting new features.
  78. Some external packages provide more functionality. See:
  79. </p>
  80. <pre><a href="https://godoc.org/?q=syslog">https://godoc.org/?q=syslog</a>
  81. </pre>
  82. </div>
  83. </div>
  84. <div id="pkg-index" class="toggleVisible">
  85. <div class="collapsed">
  86. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  87. </div>
  88. <div class="expanded">
  89. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  90. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  91. <div id="manual-nav">
  92. <dl>
  93. <dd><a href="index.html#NewLogger">func NewLogger(p Priority, logFlag int) (*log.Logger, error)</a></dd>
  94. <dd><a href="index.html#Priority">type Priority</a></dd>
  95. <dd><a href="index.html#Writer">type Writer</a></dd>
  96. <dd>&nbsp; &nbsp; <a href="index.html#Dial">func Dial(network, raddr string, priority Priority, tag string) (*Writer, error)</a></dd>
  97. <dd>&nbsp; &nbsp; <a href="index.html#New">func New(priority Priority, tag string) (w *Writer, err error)</a></dd>
  98. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Alert">func (w *Writer) Alert(m string) (err error)</a></dd>
  99. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Close">func (w *Writer) Close() error</a></dd>
  100. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Crit">func (w *Writer) Crit(m string) (err error)</a></dd>
  101. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Debug">func (w *Writer) Debug(m string) (err error)</a></dd>
  102. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Emerg">func (w *Writer) Emerg(m string) (err error)</a></dd>
  103. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Err">func (w *Writer) Err(m string) (err error)</a></dd>
  104. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Info">func (w *Writer) Info(m string) (err error)</a></dd>
  105. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Notice">func (w *Writer) Notice(m string) (err error)</a></dd>
  106. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Warning">func (w *Writer) Warning(m string) (err error)</a></dd>
  107. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Write">func (w *Writer) Write(b []byte) (int, error)</a></dd>
  108. <dd><a href="index.html#pkg-note-BUG">Bugs</a></dd>
  109. </dl>
  110. </div><!-- #manual-nav -->
  111. <h4>Package files</h4>
  112. <p>
  113. <span style="font-size:90%">
  114. <a href="http://localhost:6060/src/log/syslog/doc.go">doc.go</a>
  115. <a href="http://localhost:6060/src/log/syslog/syslog.go">syslog.go</a>
  116. <a href="http://localhost:6060/src/log/syslog/syslog_unix.go">syslog_unix.go</a>
  117. </span>
  118. </p>
  119. </div><!-- .expanded -->
  120. </div><!-- #pkg-index -->
  121. <div id="pkg-callgraph" class="toggle" style="display: none">
  122. <div class="collapsed">
  123. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  124. </div> <!-- .expanded -->
  125. <div class="expanded">
  126. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  127. <p>
  128. In the call graph viewer below, each node
  129. is a function belonging to this package
  130. and its children are the functions it
  131. calls&mdash;perhaps dynamically.
  132. </p>
  133. <p>
  134. The root nodes are the entry points of the
  135. package: functions that may be called from
  136. outside the package.
  137. There may be non-exported or anonymous
  138. functions among them if they are called
  139. dynamically from another package.
  140. </p>
  141. <p>
  142. Click a node to visit that function's source code.
  143. From there you can visit its callers by
  144. clicking its declaring <code>func</code>
  145. token.
  146. </p>
  147. <p>
  148. Functions may be omitted if they were
  149. determined to be unreachable in the
  150. particular programs or tests that were
  151. analyzed.
  152. </p>
  153. <!-- Zero means show all package entry points. -->
  154. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  155. </div>
  156. </div> <!-- #pkg-callgraph -->
  157. <h2 id="NewLogger">func <a href="http://localhost:6060/src/log/syslog/syslog.go?s=7160:7220#L296">NewLogger</a></h2>
  158. <pre>func NewLogger(p <a href="index.html#Priority">Priority</a>, logFlag <a href="../../builtin/index.html#int">int</a>) (*<a href="../index.html">log</a>.<a href="../index.html#Logger">Logger</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  159. <p>
  160. NewLogger creates a log.Logger whose output is written to
  161. the system log service with the specified priority. The logFlag
  162. argument is the flag set passed through to log.New to create
  163. the Logger.
  164. </p>
  165. <h2 id="Priority">type <a href="http://localhost:6060/src/log/syslog/syslog.go?s=521:538#L14">Priority</a></h2>
  166. <pre>type Priority <a href="../../builtin/index.html#int">int</a></pre>
  167. <p>
  168. The Priority is a combination of the syslog facility and
  169. severity. For example, LOG_ALERT | LOG_FTP sends an alert severity
  170. message from the FTP facility. The default severity is LOG_EMERG;
  171. the default facility is LOG_KERN.
  172. </p>
  173. <pre>const (
  174. <span class="comment">// From /usr/include/sys/syslog.h.</span>
  175. <span class="comment">// These are the same on Linux, BSD, and OS X.</span>
  176. <span id="LOG_EMERG">LOG_EMERG</span> <a href="index.html#Priority">Priority</a> = <a href="../../builtin/index.html#iota">iota</a>
  177. <span id="LOG_ALERT">LOG_ALERT</span>
  178. <span id="LOG_CRIT">LOG_CRIT</span>
  179. <span id="LOG_ERR">LOG_ERR</span>
  180. <span id="LOG_WARNING">LOG_WARNING</span>
  181. <span id="LOG_NOTICE">LOG_NOTICE</span>
  182. <span id="LOG_INFO">LOG_INFO</span>
  183. <span id="LOG_DEBUG">LOG_DEBUG</span>
  184. )</pre>
  185. <pre>const (
  186. <span class="comment">// From /usr/include/sys/syslog.h.</span>
  187. <span class="comment">// These are the same up to LOG_FTP on Linux, BSD, and OS X.</span>
  188. <span id="LOG_KERN">LOG_KERN</span> <a href="index.html#Priority">Priority</a> = <a href="../../builtin/index.html#iota">iota</a> &lt;&lt; 3
  189. <span id="LOG_USER">LOG_USER</span>
  190. <span id="LOG_MAIL">LOG_MAIL</span>
  191. <span id="LOG_DAEMON">LOG_DAEMON</span>
  192. <span id="LOG_AUTH">LOG_AUTH</span>
  193. <span id="LOG_SYSLOG">LOG_SYSLOG</span>
  194. <span id="LOG_LPR">LOG_LPR</span>
  195. <span id="LOG_NEWS">LOG_NEWS</span>
  196. <span id="LOG_UUCP">LOG_UUCP</span>
  197. <span id="LOG_CRON">LOG_CRON</span>
  198. <span id="LOG_AUTHPRIV">LOG_AUTHPRIV</span>
  199. <span id="LOG_FTP">LOG_FTP</span>
  200. <span id="LOG_LOCAL0">LOG_LOCAL0</span>
  201. <span id="LOG_LOCAL1">LOG_LOCAL1</span>
  202. <span id="LOG_LOCAL2">LOG_LOCAL2</span>
  203. <span id="LOG_LOCAL3">LOG_LOCAL3</span>
  204. <span id="LOG_LOCAL4">LOG_LOCAL4</span>
  205. <span id="LOG_LOCAL5">LOG_LOCAL5</span>
  206. <span id="LOG_LOCAL6">LOG_LOCAL6</span>
  207. <span id="LOG_LOCAL7">LOG_LOCAL7</span>
  208. )</pre>
  209. <h2 id="Writer">type <a href="http://localhost:6060/src/log/syslog/syslog.go?s=1273:1432#L66">Writer</a></h2>
  210. <pre>type Writer struct {
  211. <span class="comment">// contains filtered or unexported fields</span>
  212. }</pre>
  213. <p>
  214. A Writer is a connection to a syslog server.
  215. </p>
  216. <h3 id="Dial">func <a href="http://localhost:6060/src/log/syslog/syslog.go?s=2506:2586#L105">Dial</a></h3>
  217. <pre>func Dial(network, raddr <a href="../../builtin/index.html#string">string</a>, priority <a href="index.html#Priority">Priority</a>, tag <a href="../../builtin/index.html#string">string</a>) (*<a href="index.html#Writer">Writer</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  218. <p>
  219. Dial establishes a connection to a log daemon by connecting to
  220. address raddr on the specified network. Each write to the returned
  221. writer sends a log message with the given facility, severity and
  222. tag.
  223. If network is empty, Dial will connect to the local syslog server.
  224. </p>
  225. <h3 id="New">func <a href="http://localhost:6060/src/log/syslog/syslog.go?s=2119:2181#L96">New</a></h3>
  226. <pre>func New(priority <a href="index.html#Priority">Priority</a>, tag <a href="../../builtin/index.html#string">string</a>) (w *<a href="index.html#Writer">Writer</a>, err <a href="../../builtin/index.html#error">error</a>)</pre>
  227. <p>
  228. New establishes a new connection to the system log daemon. Each
  229. write to the returned writer sends a log message with the given
  230. priority and prefix.
  231. </p>
  232. <h3 id="Writer.Alert">func (*Writer) <a href="http://localhost:6060/src/log/syslog/syslog.go?s=4200:4244#L187">Alert</a></h3>
  233. <pre>func (w *<a href="index.html#Writer">Writer</a>) Alert(m <a href="../../builtin/index.html#string">string</a>) (err <a href="../../builtin/index.html#error">error</a>)</pre>
  234. <p>
  235. Alert logs a message with severity LOG_ALERT, ignoring the severity
  236. passed to New.
  237. </p>
  238. <h3 id="Writer.Close">func (*Writer) <a href="http://localhost:6060/src/log/syslog/syslog.go?s=3762:3792#L166">Close</a></h3>
  239. <pre>func (w *<a href="index.html#Writer">Writer</a>) Close() <a href="../../builtin/index.html#error">error</a></pre>
  240. <p>
  241. Close closes a connection to the syslog daemon.
  242. </p>
  243. <h3 id="Writer.Crit">func (*Writer) <a href="http://localhost:6060/src/log/syslog/syslog.go?s=4389:4432#L194">Crit</a></h3>
  244. <pre>func (w *<a href="index.html#Writer">Writer</a>) Crit(m <a href="../../builtin/index.html#string">string</a>) (err <a href="../../builtin/index.html#error">error</a>)</pre>
  245. <p>
  246. Crit logs a message with severity LOG_CRIT, ignoring the severity
  247. passed to New.
  248. </p>
  249. <h3 id="Writer.Debug">func (*Writer) <a href="http://localhost:6060/src/log/syslog/syslog.go?s=5342:5386#L229">Debug</a></h3>
  250. <pre>func (w *<a href="index.html#Writer">Writer</a>) Debug(m <a href="../../builtin/index.html#string">string</a>) (err <a href="../../builtin/index.html#error">error</a>)</pre>
  251. <p>
  252. Debug logs a message with severity LOG_DEBUG, ignoring the severity
  253. passed to New.
  254. </p>
  255. <h3 id="Writer.Emerg">func (*Writer) <a href="http://localhost:6060/src/log/syslog/syslog.go?s=4009:4053#L180">Emerg</a></h3>
  256. <pre>func (w *<a href="index.html#Writer">Writer</a>) Emerg(m <a href="../../builtin/index.html#string">string</a>) (err <a href="../../builtin/index.html#error">error</a>)</pre>
  257. <p>
  258. Emerg logs a message with severity LOG_EMERG, ignoring the severity
  259. passed to New.
  260. </p>
  261. <h3 id="Writer.Err">func (*Writer) <a href="http://localhost:6060/src/log/syslog/syslog.go?s=4574:4616#L201">Err</a></h3>
  262. <pre>func (w *<a href="index.html#Writer">Writer</a>) Err(m <a href="../../builtin/index.html#string">string</a>) (err <a href="../../builtin/index.html#error">error</a>)</pre>
  263. <p>
  264. Err logs a message with severity LOG_ERR, ignoring the severity
  265. passed to New.
  266. </p>
  267. <h3 id="Writer.Info">func (*Writer) <a href="http://localhost:6060/src/log/syslog/syslog.go?s=5153:5196#L222">Info</a></h3>
  268. <pre>func (w *<a href="index.html#Writer">Writer</a>) Info(m <a href="../../builtin/index.html#string">string</a>) (err <a href="../../builtin/index.html#error">error</a>)</pre>
  269. <p>
  270. Info logs a message with severity LOG_INFO, ignoring the severity
  271. passed to New.
  272. </p>
  273. <h3 id="Writer.Notice">func (*Writer) <a href="http://localhost:6060/src/log/syslog/syslog.go?s=4962:5007#L215">Notice</a></h3>
  274. <pre>func (w *<a href="index.html#Writer">Writer</a>) Notice(m <a href="../../builtin/index.html#string">string</a>) (err <a href="../../builtin/index.html#error">error</a>)</pre>
  275. <p>
  276. Notice logs a message with severity LOG_NOTICE, ignoring the
  277. severity passed to New.
  278. </p>
  279. <h3 id="Writer.Warning">func (*Writer) <a href="http://localhost:6060/src/log/syslog/syslog.go?s=4765:4811#L208">Warning</a></h3>
  280. <pre>func (w *<a href="index.html#Writer">Writer</a>) Warning(m <a href="../../builtin/index.html#string">string</a>) (err <a href="../../builtin/index.html#error">error</a>)</pre>
  281. <p>
  282. Warning logs a message with severity LOG_WARNING, ignoring the
  283. severity passed to New.
  284. </p>
  285. <h3 id="Writer.Write">func (*Writer) <a href="http://localhost:6060/src/log/syslog/syslog.go?s=3613:3658#L161">Write</a></h3>
  286. <pre>func (w *<a href="index.html#Writer">Writer</a>) Write(b []<a href="../../builtin/index.html#byte">byte</a>) (<a href="../../builtin/index.html#int">int</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  287. <p>
  288. Write sends a log message to the syslog daemon.
  289. </p>
  290. <h2 id="pkg-note-BUG">Bugs</h2>
  291. <ul style="list-style: none; padding: 0;">
  292. <li><a href="http://localhost:6060/src/log/syslog/doc.go?s=640:873#L9">&#x261e;</a> This package is not implemented on Windows. As the
  293. syslog package is frozen, Windows users are encouraged to
  294. use a package outside of the standard library. For background,
  295. see https://golang.org/issue/1108.
  296. </li>
  297. <li><a href="http://localhost:6060/src/log/syslog/doc.go?s=875:933#L14">&#x261e;</a> This package is not implemented on Plan 9.
  298. </li>
  299. <li><a href="http://localhost:6060/src/log/syslog/doc.go?s=935:1006#L16">&#x261e;</a> This package is not implemented on NaCl (Native Client).
  300. </li>
  301. </ul>
  302. <div id="footer">
  303. Build version go1.6.<br>
  304. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  305. the content of this page is licensed under the
  306. Creative Commons Attribution 3.0 License,
  307. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  308. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  309. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  310. </div>
  311. </div><!-- .container -->
  312. </div><!-- #page -->
  313. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  314. <script type="text/javascript" src="../../../lib/godoc/jquery.js"></script>
  315. <script type="text/javascript" src="../../../lib/godoc/jquery.treeview.js"></script>
  316. <script type="text/javascript" src="../../../lib/godoc/jquery.treeview.edit.js"></script>
  317. <script type="text/javascript" src="../../../lib/godoc/godocs.js"></script>
  318. </body>
  319. </html>