logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

tinylog.8 (5923B)


  1. .\" tinylog.8
  2. .\" wcm, 2009.09.29 - 2011.02.01
  3. .\" ===
  4. .TH tinylog 8 "January 2013" "perp-2.07" "persistent process supervision"
  5. .SH NAME
  6. tinylog \- log stdin to a directory of rotated log files
  7. .SH SYNOPSIS
  8. .B tinylog [\-hV] [\-k
  9. .I numkeep
  10. .B ] [\-r] [\-s
  11. .I logsize
  12. .B ] [\-t] [\-z]
  13. .I dir
  14. .SH DESCRIPTION
  15. .B tinylog
  16. reads lines from standard input and writes them to a set of rotated log files
  17. maintained in
  18. .IR dir .
  19. .PP
  20. While active,
  21. .B tinylog
  22. switches into
  23. .I dir
  24. and writes into a log file named
  25. .IR current .
  26. When
  27. .I current
  28. reaches the size specified with the
  29. .B -s
  30. option (default 100000 bytes),
  31. it rotates the file:
  32. .I current
  33. is renamed with a filename in the form
  34. .IR _yyyymmddThhmmss.uuuuuu.s ,
  35. and a new
  36. .I current
  37. is opened.
  38. .PP
  39. .B tinylog
  40. maintains a set of older rotated log files in
  41. .IR dir ,
  42. upto the number specified with the
  43. .B -k
  44. option (default 5).
  45. After this number is reached,
  46. .B tinylog
  47. deletes the rotated log file with the oldest timestamp before
  48. continuing with a new
  49. .IR current .
  50. .PP
  51. If the
  52. .B -z
  53. option is specified,
  54. .B tinylog
  55. will compress log files during rotation with the utility specified in the
  56. environmental variable
  57. .B TINYLOG_ZIP
  58. (default
  59. .IR /usr/bin/gzip ).
  60. If the compression is successful,
  61. the rotated log file is renamed with a
  62. .I .Z
  63. extension.
  64. .PP
  65. The name of a rotated log file may be described further:
  66. beginning with an underscore,
  67. followed by a current
  68. .B gmtime(3)
  69. timestamp in RFC8601 format (to the nearest microsecond),
  70. followed by a status suffix,
  71. and optionally followed by a
  72. .I .Z
  73. zip extension.
  74. Normally the status suffix is
  75. .IR .s ,
  76. indicating the file was safely written to disk.
  77. Otherwise a status suffix of
  78. .I .u
  79. indicates that the file was not safely written to disk,
  80. and may possibly be incomplete and/or corrupted by an unexpected failure.
  81. .PP
  82. .B tinylog
  83. sets the file mode of
  84. .I current
  85. to 0644 while active.
  86. When
  87. .B tinylog
  88. sees eof on stdin,
  89. it writes any pending line to
  90. .IR current ,
  91. fsyncs and closes the file,
  92. and changes its mode to 0744 before exiting.
  93. Whenever
  94. .B tinylog
  95. restarts,
  96. it looks for an existing
  97. .I current
  98. and,
  99. if one is found with a file mode 0744,
  100. reopens it and changes its mode back to 0644 for continued logging.
  101. Otherwise,
  102. if an existing
  103. .I current
  104. is found set with a mode of 0644,
  105. it is immediately rotated with a
  106. .I .u
  107. suffix,
  108. and a new
  109. .I current
  110. is opened.
  111. .PP
  112. .B tinylog
  113. ignores empty lines,
  114. truncates lines longer than 1000 characters,
  115. and converts unprintable control characters to `?'.
  116. .SH OPTIONS
  117. .TP
  118. .B \-h
  119. Help.
  120. Print a brief usage message to stderr and exit.
  121. .TP
  122. .B \-k numkeep
  123. Keep.
  124. Sets the maximum number of log files that
  125. .B tinylog
  126. will keep after rotation.
  127. Whenever
  128. .B tinylog
  129. rotates the most recent log file,
  130. it deletes any more than
  131. .I numkeep
  132. older log files found in the directory.
  133. The minimum number is 0,
  134. in which case no older log files are kept.
  135. If not specified,
  136. the default number of older log files kept is 5.
  137. .TP
  138. .B \-r
  139. Rotate on start.
  140. Normally on start-up,
  141. .B tinylog
  142. begins logging with an existing
  143. .I current
  144. file if it has been safely closed from a previous session.
  145. The
  146. .B \-r
  147. option causes
  148. .B tinylog
  149. to immediately rotate any existing
  150. .I current
  151. file and begin logging with a new one.
  152. .TP
  153. .B \-s logsize
  154. Size.
  155. Sets the maximum size (in bytes) that a log file may grow before
  156. rotation.
  157. The minimum size is 2000.
  158. The default size is 100000.
  159. .TP
  160. .B -t
  161. Timestamp.
  162. A current
  163. .B gmtime(3)
  164. timestamp string in the form of ``yyyymmddThhmmss.uuuuuu'' is prepended
  165. to each line written to the log file.
  166. .TP
  167. .B \-V
  168. Version.
  169. Print the version number to stderr and exit.
  170. .TP
  171. .B \-z
  172. Zip.
  173. This option instructs
  174. .B tinylog
  175. to run a compression utility when it rotates the log file.
  176. The compression utility may be specified in the environmental variable
  177. .BR TINYLOG_ZIP .
  178. If the variable is not set or empty,
  179. .B tinylog
  180. will use a compiled-in default,
  181. usually
  182. .IR /usr/bin/gzip .
  183. The compression utility should be designed to run without any arguments,
  184. reading from stdin and writing to stdout.
  185. After successful compression,
  186. .B tinylog
  187. will rename the rotated log file with a
  188. .I .Z
  189. extension.
  190. .SH ENVIRONMENT
  191. TINYLOG_ZIP
  192. .RS
  193. If defined and the
  194. .B \-z
  195. option is specified,
  196. will be taken as the executable for the compression utility to use when rotating a log file.
  197. .RE
  198. .SH SIGNALS
  199. .B tinylog
  200. traps the following signals for adminstrative control during runtime:
  201. .PP
  202. SIGHUP
  203. .RS
  204. Close and rotate
  205. .IR current ,
  206. then continue logging with a new
  207. .IR current .
  208. .RE
  209. .PP
  210. SIGTERM
  211. .RS
  212. Stop reading stdin,
  213. process any pending lines already read,
  214. flush and close
  215. .IR current
  216. safely to disk,
  217. then exit 0 (no error).
  218. Stdin will be left at the first byte of any unprocessed data.
  219. .RE
  220. .SH EXIT STATUS
  221. .B tinylog
  222. exits with the following values:
  223. .TP
  224. 0
  225. Normally
  226. .B tinylog
  227. runs until eof is found on stdin,
  228. or until it receives a
  229. .B TERM
  230. signal.
  231. In these cases,
  232. .B tinylog
  233. writes any pending lines to the log,
  234. flushes and closes
  235. .IR current ,
  236. changes its mode to 0744,
  237. and exits 0.
  238. .TP
  239. 100
  240. .B tinylog
  241. failed on startup because of some usage error,
  242. such as invalid command-line option or missing argument.
  243. In this case
  244. .B tinylog
  245. will print a brief diagnostic to stderr on exit.
  246. .TP
  247. 111
  248. .B tinylog
  249. found another instance or active lockfile running in
  250. .IR dir ,
  251. or failed due to some other system or resource error on startup.
  252. In this case
  253. .B tinylog
  254. will print a brief diagnostic to stderr on exit.
  255. .PP
  256. Otherwise,
  257. after startup,
  258. .B tinylog
  259. tries very hard not to exit until eof is read on stdin.
  260. In the case of system or resource failures,
  261. .B tinylog
  262. will print a diagnostic message to stderr,
  263. pause for a brief interval,
  264. and then retry the failed operation.
  265. .SH AUTHOR
  266. Wayne Marshall, http://b0llix.net/perp/
  267. .SH SEE ALSO
  268. .nh
  269. .BR perp_intro (8),
  270. .BR perpboot (8),
  271. .BR perpctl (8),
  272. .BR perpd (8),
  273. .BR perpetrate (5),
  274. .BR perphup (8),
  275. .BR perpls (8),
  276. .BR perpok (8),
  277. .BR perpstat (8),
  278. .BR sissylog (8)
  279. .\" EOF tinylog.8