@contrast/agent 4.32.11 → 4.32.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/lib/core/config/util.js +2 -1
  2. package/node_modules/file-stream-rotator/FileStreamRotator.js +200 -41
  3. package/node_modules/file-stream-rotator/LICENSE.txt +17 -0
  4. package/node_modules/file-stream-rotator/README.md +16 -1
  5. package/node_modules/file-stream-rotator/package.json +5 -5
  6. package/node_modules/file-stream-rotator/tests/every-minute-test.js +32 -15
  7. package/node_modules/file-stream-rotator/tests/every-second-test.js +16 -7
  8. package/node_modules/file-stream-rotator/tests/large-test.js +33 -0
  9. package/node_modules/file-stream-rotator/tests/rotate-on-size-without-date.js +103 -0
  10. package/node_modules/object-hash/dist/object_hash.js +1 -2
  11. package/node_modules/object-hash/index.js +33 -21
  12. package/node_modules/object-hash/package.json +20 -18
  13. package/node_modules/object-hash/readme.markdown +20 -5
  14. package/node_modules/winston-daily-rotate-file/README.md +81 -12
  15. package/node_modules/winston-daily-rotate-file/daily-rotate-file.js +69 -30
  16. package/node_modules/winston-daily-rotate-file/index.d.ts +119 -72
  17. package/node_modules/winston-daily-rotate-file/package.json +20 -19
  18. package/node_modules/winston-transport/.eslintrc +1 -1
  19. package/node_modules/winston-transport/.nyc_output/c3d7ddb9-cc26-466b-a4f6-993ad69e86f6.json +1 -0
  20. package/node_modules/winston-transport/.nyc_output/processinfo/c3d7ddb9-cc26-466b-a4f6-993ad69e86f6.json +1 -0
  21. package/node_modules/winston-transport/.nyc_output/processinfo/index.json +1 -1
  22. package/node_modules/winston-transport/CHANGELOG.md +11 -0
  23. package/node_modules/winston-transport/dist/index.js +2 -2
  24. package/node_modules/winston-transport/index.d.ts +2 -0
  25. package/node_modules/winston-transport/index.js +2 -2
  26. package/node_modules/winston-transport/node_modules/readable-stream/README.md +106 -0
  27. package/node_modules/winston-transport/node_modules/readable-stream/errors-browser.js +127 -0
  28. package/node_modules/winston-transport/node_modules/readable-stream/errors.js +116 -0
  29. package/node_modules/winston-transport/node_modules/readable-stream/experimentalWarning.js +17 -0
  30. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_duplex.js +41 -46
  31. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_passthrough.js +1 -11
  32. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_readable.js +271 -263
  33. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_transform.js +18 -42
  34. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_writable.js +101 -147
  35. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
  36. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
  37. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
  38. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
  39. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
  40. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
  41. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
  42. package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
  43. package/node_modules/winston-transport/node_modules/readable-stream/package.json +72 -0
  44. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/readable-browser.js +2 -0
  45. package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/readable.js +5 -8
  46. package/node_modules/winston-transport/package.json +16 -14
  47. package/package.json +7 -7
  48. package/node_modules/colors/LICENSE +0 -25
  49. package/node_modules/colors/README.md +0 -221
  50. package/node_modules/colors/examples/normal-usage.js +0 -82
  51. package/node_modules/colors/examples/safe-string.js +0 -79
  52. package/node_modules/colors/index.d.ts +0 -136
  53. package/node_modules/colors/lib/colors.js +0 -211
  54. package/node_modules/colors/lib/custom/trap.js +0 -46
  55. package/node_modules/colors/lib/custom/zalgo.js +0 -110
  56. package/node_modules/colors/lib/extendStringPrototype.js +0 -110
  57. package/node_modules/colors/lib/index.js +0 -13
  58. package/node_modules/colors/lib/maps/america.js +0 -10
  59. package/node_modules/colors/lib/maps/rainbow.js +0 -12
  60. package/node_modules/colors/lib/maps/random.js +0 -11
  61. package/node_modules/colors/lib/maps/zebra.js +0 -5
  62. package/node_modules/colors/lib/styles.js +0 -95
  63. package/node_modules/colors/lib/system/has-flag.js +0 -35
  64. package/node_modules/colors/lib/system/supports-colors.js +0 -151
  65. package/node_modules/colors/package.json +0 -49
  66. package/node_modules/colors/safe.d.ts +0 -48
  67. package/node_modules/colors/safe.js +0 -10
  68. package/node_modules/colors/themes/generic-logging.js +0 -12
  69. package/node_modules/core-util-is/LICENSE +0 -19
  70. package/node_modules/core-util-is/README.md +0 -3
  71. package/node_modules/core-util-is/float.patch +0 -604
  72. package/node_modules/core-util-is/lib/util.js +0 -107
  73. package/node_modules/core-util-is/package.json +0 -36
  74. package/node_modules/core-util-is/test.js +0 -68
  75. package/node_modules/cycle/README.md +0 -49
  76. package/node_modules/cycle/cycle.js +0 -170
  77. package/node_modules/cycle/package.json +0 -16
  78. package/node_modules/fast-safe-stringify/.travis.yml +0 -8
  79. package/node_modules/fast-safe-stringify/CHANGELOG.md +0 -17
  80. package/node_modules/fast-safe-stringify/LICENSE +0 -23
  81. package/node_modules/fast-safe-stringify/benchmark.js +0 -137
  82. package/node_modules/fast-safe-stringify/index.d.ts +0 -8
  83. package/node_modules/fast-safe-stringify/index.js +0 -161
  84. package/node_modules/fast-safe-stringify/package.json +0 -50
  85. package/node_modules/fast-safe-stringify/readme.md +0 -154
  86. package/node_modules/fast-safe-stringify/test-stable.js +0 -311
  87. package/node_modules/fast-safe-stringify/test.js +0 -304
  88. package/node_modules/isarray/.npmignore +0 -1
  89. package/node_modules/isarray/.travis.yml +0 -4
  90. package/node_modules/isarray/Makefile +0 -6
  91. package/node_modules/isarray/README.md +0 -60
  92. package/node_modules/isarray/component.json +0 -19
  93. package/node_modules/isarray/index.js +0 -5
  94. package/node_modules/isarray/package.json +0 -49
  95. package/node_modules/isarray/test.js +0 -20
  96. package/node_modules/object-hash/.jshintrc +0 -19
  97. package/node_modules/object-hash/.travis.yml +0 -35
  98. package/node_modules/object-hash/bower.json +0 -15
  99. package/node_modules/object-hash/dist/object_hash.js.map +0 -1
  100. package/node_modules/object-hash/dist/object_hash_test.js +0 -4737
  101. package/node_modules/object-hash/gulpfile.js +0 -97
  102. package/node_modules/object-hash/karma.conf.js +0 -69
  103. package/node_modules/object-hash/test/blob.js +0 -41
  104. package/node_modules/object-hash/test/index.js +0 -290
  105. package/node_modules/object-hash/test/object-classes.js +0 -106
  106. package/node_modules/object-hash/test/old-crypto.js +0 -60
  107. package/node_modules/object-hash/test/replacer.js +0 -36
  108. package/node_modules/object-hash/test/types.js +0 -174
  109. package/node_modules/object-hash/test/writeToStream.js +0 -27
  110. package/node_modules/process-nextick-args/index.js +0 -45
  111. package/node_modules/process-nextick-args/license.md +0 -19
  112. package/node_modules/process-nextick-args/package.json +0 -29
  113. package/node_modules/process-nextick-args/readme.md +0 -18
  114. package/node_modules/readable-stream/.travis.yml +0 -34
  115. package/node_modules/readable-stream/README.md +0 -58
  116. package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
  117. package/node_modules/readable-stream/duplex-browser.js +0 -1
  118. package/node_modules/readable-stream/duplex.js +0 -1
  119. package/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -79
  120. package/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -74
  121. package/node_modules/readable-stream/package.json +0 -56
  122. package/node_modules/readable-stream/passthrough.js +0 -1
  123. package/node_modules/readable-stream/transform.js +0 -1
  124. package/node_modules/readable-stream/writable-browser.js +0 -1
  125. package/node_modules/readable-stream/writable.js +0 -8
  126. package/node_modules/winston-compat/.gitattributes +0 -1
  127. package/node_modules/winston-compat/.node-version +0 -1
  128. package/node_modules/winston-compat/CHANGELOG.md +0 -17
  129. package/node_modules/winston-compat/LICENSE +0 -22
  130. package/node_modules/winston-compat/README.md +0 -2
  131. package/node_modules/winston-compat/index.js +0 -295
  132. package/node_modules/winston-compat/lib/transport.js +0 -135
  133. package/node_modules/winston-compat/node_modules/fecha/CHANGELOG.md +0 -11
  134. package/node_modules/winston-compat/node_modules/fecha/LICENSE +0 -22
  135. package/node_modules/winston-compat/node_modules/fecha/README.md +0 -259
  136. package/node_modules/winston-compat/node_modules/fecha/fecha.d.ts +0 -47
  137. package/node_modules/winston-compat/node_modules/fecha/fecha.js +0 -334
  138. package/node_modules/winston-compat/node_modules/fecha/fecha.min.js +0 -1
  139. package/node_modules/winston-compat/node_modules/fecha/package.json +0 -44
  140. package/node_modules/winston-compat/node_modules/logform/.babelrc +0 -3
  141. package/node_modules/winston-compat/node_modules/logform/.eslintrc +0 -7
  142. package/node_modules/winston-compat/node_modules/logform/.gitattributes +0 -1
  143. package/node_modules/winston-compat/node_modules/logform/.travis.yml +0 -17
  144. package/node_modules/winston-compat/node_modules/logform/CHANGELOG.md +0 -103
  145. package/node_modules/winston-compat/node_modules/logform/LICENSE +0 -21
  146. package/node_modules/winston-compat/node_modules/logform/README.md +0 -170
  147. package/node_modules/winston-compat/node_modules/logform/align.js +0 -14
  148. package/node_modules/winston-compat/node_modules/logform/browser.js +0 -36
  149. package/node_modules/winston-compat/node_modules/logform/cli.js +0 -52
  150. package/node_modules/winston-compat/node_modules/logform/colorize.js +0 -118
  151. package/node_modules/winston-compat/node_modules/logform/combine.js +0 -66
  152. package/node_modules/winston-compat/node_modules/logform/dist/align.js +0 -14
  153. package/node_modules/winston-compat/node_modules/logform/dist/browser.js +0 -37
  154. package/node_modules/winston-compat/node_modules/logform/dist/cli.js +0 -75
  155. package/node_modules/winston-compat/node_modules/logform/dist/colorize.js +0 -147
  156. package/node_modules/winston-compat/node_modules/logform/dist/combine.js +0 -66
  157. package/node_modules/winston-compat/node_modules/logform/dist/format.js +0 -69
  158. package/node_modules/winston-compat/node_modules/logform/dist/index.js +0 -54
  159. package/node_modules/winston-compat/node_modules/logform/dist/json.js +0 -27
  160. package/node_modules/winston-compat/node_modules/logform/dist/label.js +0 -19
  161. package/node_modules/winston-compat/node_modules/logform/dist/levels.js +0 -15
  162. package/node_modules/winston-compat/node_modules/logform/dist/logstash.js +0 -32
  163. package/node_modules/winston-compat/node_modules/logform/dist/metadata.js +0 -63
  164. package/node_modules/winston-compat/node_modules/logform/dist/ms.js +0 -18
  165. package/node_modules/winston-compat/node_modules/logform/dist/pad-levels.js +0 -118
  166. package/node_modules/winston-compat/node_modules/logform/dist/pretty-print.js +0 -20
  167. package/node_modules/winston-compat/node_modules/logform/dist/printf.js +0 -40
  168. package/node_modules/winston-compat/node_modules/logform/dist/simple.js +0 -36
  169. package/node_modules/winston-compat/node_modules/logform/dist/splat.js +0 -147
  170. package/node_modules/winston-compat/node_modules/logform/dist/timestamp.js +0 -28
  171. package/node_modules/winston-compat/node_modules/logform/dist/uncolorize.js +0 -31
  172. package/node_modules/winston-compat/node_modules/logform/examples/combine.js +0 -14
  173. package/node_modules/winston-compat/node_modules/logform/examples/filter.js +0 -30
  174. package/node_modules/winston-compat/node_modules/logform/examples/invalid.js +0 -6
  175. package/node_modules/winston-compat/node_modules/logform/examples/metadata.js +0 -78
  176. package/node_modules/winston-compat/node_modules/logform/examples/padLevels.js +0 -39
  177. package/node_modules/winston-compat/node_modules/logform/examples/volume.js +0 -25
  178. package/node_modules/winston-compat/node_modules/logform/format.js +0 -52
  179. package/node_modules/winston-compat/node_modules/logform/index.d.ts +0 -53
  180. package/node_modules/winston-compat/node_modules/logform/index.js +0 -52
  181. package/node_modules/winston-compat/node_modules/logform/json.js +0 -26
  182. package/node_modules/winston-compat/node_modules/logform/label.js +0 -19
  183. package/node_modules/winston-compat/node_modules/logform/levels.js +0 -12
  184. package/node_modules/winston-compat/node_modules/logform/logstash.js +0 -29
  185. package/node_modules/winston-compat/node_modules/logform/metadata.js +0 -61
  186. package/node_modules/winston-compat/node_modules/logform/ms.js +0 -18
  187. package/node_modules/winston-compat/node_modules/logform/package.json +0 -51
  188. package/node_modules/winston-compat/node_modules/logform/pad-levels.js +0 -83
  189. package/node_modules/winston-compat/node_modules/logform/pretty-print.js +0 -16
  190. package/node_modules/winston-compat/node_modules/logform/printf.js +0 -26
  191. package/node_modules/winston-compat/node_modules/logform/simple.js +0 -33
  192. package/node_modules/winston-compat/node_modules/logform/splat.js +0 -125
  193. package/node_modules/winston-compat/node_modules/logform/timestamp.js +0 -30
  194. package/node_modules/winston-compat/node_modules/logform/tsconfig.json +0 -22
  195. package/node_modules/winston-compat/node_modules/logform/uncolorize.js +0 -27
  196. package/node_modules/winston-compat/package.json +0 -46
  197. package/node_modules/winston-compat/test/clone.test.js +0 -25
  198. package/node_modules/winston-compat/test/helpers.js +0 -256
  199. package/node_modules/winston-compat/test/timestamp.test.js +0 -14
  200. package/node_modules/winston-compat/test/transports/transport.js +0 -205
  201. package/node_modules/winston-compat/test/winston-compat.test.js +0 -18
  202. package/node_modules/winston-daily-rotate-file/.eslintrc.js +0 -11
  203. package/node_modules/winston-daily-rotate-file/.node-version +0 -1
  204. package/node_modules/winston-daily-rotate-file/.travis.yml +0 -15
  205. package/node_modules/winston-daily-rotate-file/node_modules/semver/CHANGELOG.md +0 -70
  206. package/node_modules/winston-daily-rotate-file/node_modules/semver/LICENSE +0 -15
  207. package/node_modules/winston-daily-rotate-file/node_modules/semver/README.md +0 -443
  208. package/node_modules/winston-daily-rotate-file/node_modules/semver/bin/semver.js +0 -174
  209. package/node_modules/winston-daily-rotate-file/node_modules/semver/package.json +0 -32
  210. package/node_modules/winston-daily-rotate-file/node_modules/semver/range.bnf +0 -16
  211. package/node_modules/winston-daily-rotate-file/node_modules/semver/semver.js +0 -1596
  212. package/node_modules/winston-daily-rotate-file/test/memory-stream.js +0 -38
  213. package/node_modules/winston-daily-rotate-file/test/random-string.js +0 -31
  214. package/node_modules/winston-daily-rotate-file/test/transport-tests.js +0 -250
  215. package/node_modules/winston-transport/.nyc_output/1c69f3e4-4c25-457d-9df5-dfa761729528.json +0 -1
  216. package/node_modules/winston-transport/.nyc_output/processinfo/1c69f3e4-4c25-457d-9df5-dfa761729528.json +0 -1
  217. package/node_modules/winston-transport/.travis.yml +0 -17
  218. package/node_modules/winston-transport/tsconfig.json +0 -22
  219. /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/CONTRIBUTING.md +0 -0
  220. /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/GOVERNANCE.md +0 -0
  221. /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/LICENSE +0 -0
  222. /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/internal/streams/stream-browser.js +0 -0
  223. /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/internal/streams/stream.js +0 -0
@@ -1,11 +1,16 @@
1
1
  # winston-daily-rotate-file
2
2
 
3
- [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]
3
+ [![NPM version][npm-image]][npm-url]
4
+
5
+ [![NPM](https://nodei.co/npm/winston-daily-rotate-file.png)](https://nodei.co/npm/winston-daily-rotate-file/)
4
6
 
5
7
  A transport for [winston](https://github.com/winstonjs/winston) which logs to a rotating file. Logs can be rotated based on a date, size limit, and old logs can be removed based on count or elapsed days.
6
8
 
7
9
  Starting with version 2.0.0, the transport has been refactored to leverage the the [file-stream-rotator](https://github.com/rogerc/file-stream-rotator/) module. _Some of the options in the 1.x versions of the transport have changed._ Please review the options below to identify any changes needed.
8
10
 
11
+ ## Compatibility
12
+ Please note that if you are using `winston@2`, you will need to use `winston-daily-rotate-file@3`. `winston-daily-rotate-file@4` removed support for `winston@2`.
13
+
9
14
  ## Install
10
15
  ```
11
16
  npm install winston-daily-rotate-file
@@ -15,22 +20,27 @@ npm install winston-daily-rotate-file
15
20
  The DailyRotateFile transport can rotate files by minute, hour, day, month, year or weekday. In addition to the options accepted by the logger, `winston-daily-rotate-file` also accepts the following options:
16
21
 
17
22
  * **frequency:** A string representing the frequency of rotation. This is useful if you want to have timed rotations, as opposed to rotations that happen at specific moments in time. Valid values are '#m' or '#h' (e.g., '5m' or '3h'). Leaving this null relies on `datePattern` for the rotation times. (default: null)
18
- * **datePattern:** A string representing the [moment.js date format](http://momentjs.com/docs/#/displaying/format/) to be used for rotating. The meta characters used in this string will dictate the frequency of the file rotation. For example, if your datePattern is simply 'HH' you will end up with 24 log files that are picked up and appended to every day. (default 'YYYY-MM-DD')
19
- * **zippedArchive:** A boolean to define whether or not to gzip archived log files. (default 'false')
20
- * **filename:** Filename to be used to log to. This filename can include the `%DATE%` placeholder which will include the formatted datePattern at that point in the filename. (default: 'winston.log.%DATE%)
23
+ * **datePattern:** A string representing the [moment.js date format](http://momentjs.com/docs/#/displaying/format/) to be used for rotating. The meta characters used in this string will dictate the frequency of the file rotation. For example, if your datePattern is simply 'HH' you will end up with 24 log files that are picked up and appended to every day. (default: 'YYYY-MM-DD')
24
+ * **zippedArchive:** A boolean to define whether or not to gzip archived log files. (default: 'false')
25
+ * **filename:** Filename to be used to log to. This filename can include the `%DATE%` placeholder which will include the formatted datePattern at that point in the filename. (default: 'winston.log.%DATE%')
21
26
  * **dirname:** The directory name to save log files to. (default: '.')
22
27
  * **stream:** Write directly to a custom stream and bypass the rotation capabilities. (default: null)
23
28
  * **maxSize:** Maximum size of the file after which it will rotate. This can be a number of bytes, or units of kb, mb, and gb. If using the units, add 'k', 'm', or 'g' as the suffix. The units need to directly follow the number. (default: null)
24
- * **maxFiles:** Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null)
29
+ * **maxFiles:** Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. It uses auditFile to keep track of the log files in a json format. It won't delete any file not contained in it. It can be a number of files or number of days (default: null)
25
30
  * **options:** An object resembling https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options indicating additional options that should be passed to the file stream. (default: `{ flags: 'a' }`)
26
- * **auditFile**: A string representing the name of the name of the audit file. This can be used to override the default filename which is generated by computing a hash of the options object. (default: '.<optionsHash>.json')
31
+ * **auditFile**: A string representing the name of the audit file. This can be used to override the default filename which is generated by computing a hash of the options object. (default: '.<optionsHash>.json')
32
+ * **utc**: Use UTC time for date in filename. (default: false)
33
+ * **extension**: File extension to be appended to the filename. (default: '')
34
+ * **createSymlink**: Create a tailable symlink to the current active log file. (default: false)
35
+ * **symlinkName**: The name of the tailable symlink. (default: 'current.log')
36
+ * **auditHashType**: Use specified hashing algorithm for audit. (default: 'sha256')
27
37
 
28
38
  ## Usage
29
39
  ``` js
30
40
  var winston = require('winston');
31
41
  require('winston-daily-rotate-file');
32
42
 
33
- var transport = new (winston.transports.DailyRotateFile)({
43
+ var transport = new winston.transports.DailyRotateFile({
34
44
  filename: 'application-%DATE%.log',
35
45
  datePattern: 'YYYY-MM-DD-HH',
36
46
  zippedArchive: true,
@@ -49,9 +59,72 @@ The DailyRotateFile transport can rotate files by minute, hour, day, month, year
49
59
  });
50
60
 
51
61
  logger.info('Hello World!');
62
+
52
63
  ```
53
64
 
54
- This transport emits three custom events: *new*, *rotate*, and *archive*. You can listen for the *new* custom event, which is fired when a new log file is created. The new event will pass one parameter to the callback (*newFilename*). You can listen for the *rotate* custom event, which is fired when the log file is rotated. The rotate event will pass two parameters to the callback (*oldFilename*, *newFilename*). You can also listen for the *archive* custom event, which is fired when the log file is archived. The archive event will pass one parameter to the callback (*zipFilename*).
65
+ ### ES6
66
+
67
+ ``` js
68
+ import * as winston from 'winston';
69
+ import 'winston-daily-rotate-file';
70
+
71
+
72
+ const transport = new winston.transports.DailyRotateFile({
73
+ filename: 'application-%DATE%.log',
74
+ datePattern: 'YYYY-MM-DD-HH',
75
+ zippedArchive: true,
76
+ maxSize: '20m',
77
+ maxFiles: '14d'
78
+ });
79
+
80
+ transport.on('rotate', function(oldFilename, newFilename) {
81
+ // do something fun
82
+ });
83
+
84
+ const logger = winston.createLogger({
85
+ transports: [
86
+ transport
87
+ ]
88
+ });
89
+
90
+ logger.info('Hello World!');
91
+ ```
92
+
93
+ ### Typescript
94
+
95
+ ``` typescript
96
+
97
+ import * as winston from 'winston';
98
+ import DailyRotateFile from 'winston-daily-rotate-file';
99
+
100
+ const transport: DailyRotateFile = new DailyRotateFile({
101
+ filename: 'application-%DATE%.log',
102
+ datePattern: 'YYYY-MM-DD-HH',
103
+ zippedArchive: true,
104
+ maxSize: '20m',
105
+ maxFiles: '14d'
106
+ });
107
+
108
+ transport.on('rotate', function(oldFilename, newFilename) {
109
+ // do something fun
110
+ });
111
+
112
+ const logger = winston.createLogger({
113
+ transports: [
114
+ transport
115
+ ]});
116
+
117
+ logger.info('Hello World!');
118
+
119
+ ```
120
+
121
+
122
+ This transport emits the following custom events:
123
+
124
+ * **new**: fired when a new log file is created. This event will pass one parameter to the callback (*newFilename*).
125
+ * **rotate**: fired when the log file is rotated. This event will pass two parameters to the callback (*oldFilename*, *newFilename*).
126
+ * **archive**: fired when the log file is archived. This event will pass one parameter to the callback (*zipFilename*).
127
+ * **logRemoved**: fired when a log file is removed from the file system. This event will pass one parameter to the callback (*removedFilename*).
55
128
 
56
129
  ## LICENSE
57
130
  MIT
@@ -61,7 +134,3 @@ MIT
61
134
 
62
135
  [npm-image]: https://badge.fury.io/js/winston-daily-rotate-file.svg
63
136
  [npm-url]: https://npmjs.org/package/winston-daily-rotate-file
64
- [travis-image]: https://travis-ci.org/winstonjs/winston-daily-rotate-file.svg?branch=master
65
- [travis-url]: https://travis-ci.org/winstonjs/winston-daily-rotate-file
66
- [daviddm-image]: https://david-dm.org/winstonjs/winston-daily-rotate-file.svg?theme=shields.io
67
- [daviddm-url]: https://david-dm.org/winstonjs/winston-daily-rotate-file
@@ -4,14 +4,11 @@ var fs = require('fs');
4
4
  var os = require('os');
5
5
  var path = require('path');
6
6
  var util = require('util');
7
- var semver = require('semver');
8
7
  var zlib = require('zlib');
9
8
  var hash = require('object-hash');
10
- var winston = require('winston');
11
- var compat = require('winston-compat');
12
9
  var MESSAGE = require('triple-beam').MESSAGE;
13
10
  var PassThrough = require('stream').PassThrough;
14
- var Transport = semver.major(winston.version) === 2 ? compat.Transport : require('winston-transport');
11
+ var Transport = require('winston-transport');
15
12
 
16
13
  var loggerDefaults = {
17
14
  json: false,
@@ -89,7 +86,13 @@ var DailyRotateFile = function (options) {
89
86
  max_logs: options.maxFiles,
90
87
  end_stream: true,
91
88
  audit_file: options.auditFile ? options.auditFile : path.join(self.dirname, '.' + hash(options) + '-audit.json'),
92
- file_options: options.options ? options.options : {flags: 'a'}
89
+ file_options: options.options ? options.options : {flags: 'a'},
90
+ utc: options.utc ? options.utc : false,
91
+ extension: options.extension ? options.extension : '',
92
+ create_symlink: options.createSymlink ? options.createSymlink : false,
93
+ symlink_name: options.symlinkName ? options.symlinkName : 'current.log',
94
+ watch_log: options.watchLog ? options.watchLog : false,
95
+ audit_hash_type: options.auditHashType ? options.auditHashType : 'sha256'
93
96
  });
94
97
 
95
98
  this.logStream.on('new', function (newFile) {
@@ -100,6 +103,27 @@ var DailyRotateFile = function (options) {
100
103
  self.emit('rotate', oldFile, newFile);
101
104
  });
102
105
 
106
+ this.logStream.on('logRemoved', function (params) {
107
+ if (options.zippedArchive) {
108
+ var gzName = params.name + '.gz';
109
+ if (fs.existsSync(gzName)) {
110
+ try {
111
+ fs.unlinkSync(gzName);
112
+ }
113
+ catch (_err) {
114
+ // file is there but we got an error when trying to delete,
115
+ // so permissions problem or concurrency issue and another
116
+ // process already deleted it we could detect the concurrency
117
+ // issue by checking err.type === ENOENT or EACCESS for
118
+ // permissions ... but then?
119
+ }
120
+ self.emit('logRemoved', gzName);
121
+ return;
122
+ }
123
+ }
124
+ self.emit('logRemoved', params.name);
125
+ });
126
+
103
127
  if (options.zippedArchive) {
104
128
  this.logStream.on('rotate', function (oldFile) {
105
129
  var oldFileExist = fs.existsSync(oldFile);
@@ -112,11 +136,19 @@ var DailyRotateFile = function (options) {
112
136
  var inp = fs.createReadStream(oldFile);
113
137
  var out = fs.createWriteStream(oldFile + '.gz');
114
138
  inp.pipe(gzip).pipe(out).on('finish', function () {
115
- fs.unlinkSync(oldFile);
139
+ if (fs.existsSync(oldFile)) {
140
+ fs.unlinkSync(oldFile);
141
+ }
116
142
  self.emit('archive', oldFile + '.gz');
117
143
  });
118
144
  });
119
145
  }
146
+
147
+ if (options.watchLog) {
148
+ this.logStream.on('addWatcher', (newFile) => {
149
+ self.emit('addWatcher', newFile);
150
+ })
151
+ }
120
152
  }
121
153
  };
122
154
 
@@ -127,29 +159,13 @@ util.inherits(DailyRotateFile, Transport);
127
159
  DailyRotateFile.prototype.name = 'dailyRotateFile';
128
160
 
129
161
  var noop = function () {};
130
- if (semver.major(winston.version) === 2) {
131
- DailyRotateFile.prototype.log = function (level, msg, meta, callback) {
132
- callback = callback || noop;
133
- var options = Object.assign({}, this.options, {
134
- level: level,
135
- message: msg,
136
- meta: meta
137
- });
162
+ DailyRotateFile.prototype.log = function (info, callback) {
163
+ callback = callback || noop;
138
164
 
139
- var output = compat.log(options) + options.eol;
140
- this.logStream.write(output);
141
- callback(null, true);
142
- };
143
- } else {
144
- DailyRotateFile.prototype.normalizeQuery = compat.Transport.prototype.normalizeQuery;
145
- DailyRotateFile.prototype.log = function (info, callback) {
146
- callback = callback || noop;
147
-
148
- this.logStream.write(info[MESSAGE] + this.options.eol);
149
- this.emit('logged', info);
150
- callback(null, true);
151
- };
152
- }
165
+ this.logStream.write(info[MESSAGE] + this.options.eol);
166
+ this.emit('logged', info);
167
+ callback(null, true);
168
+ };
153
169
 
154
170
  DailyRotateFile.prototype.close = function () {
155
171
  var self = this;
@@ -176,7 +192,28 @@ DailyRotateFile.prototype.query = function (options, callback) {
176
192
 
177
193
  var self = this;
178
194
  var results = [];
179
- options = self.normalizeQuery(options);
195
+ options = options || {};
196
+
197
+ // limit
198
+ options.rows = options.rows || options.limit || 10;
199
+
200
+ // starting row offset
201
+ options.start = options.start || 0;
202
+
203
+ // now
204
+ options.until = options.until || new Date;
205
+ if (typeof options.until !== 'object') {
206
+ options.until = new Date(options.until);
207
+ }
208
+
209
+ // now - 24
210
+ options.from = options.from || (options.until - (24 * 60 * 60 * 1000));
211
+ if (typeof options.from !== 'object') {
212
+ options.from = new Date(options.from);
213
+ }
214
+
215
+ // 'asc' or 'desc'
216
+ options.order = options.order || 'desc';
180
217
 
181
218
  var logFiles = (function () {
182
219
  var fileRegex = new RegExp(self.filename.replace('%DATE%', '.*'), 'i');
@@ -277,7 +314,9 @@ DailyRotateFile.prototype.query = function (options, callback) {
277
314
  }
278
315
 
279
316
  var time = new Date(log.timestamp);
280
- if ((options.from && time < options.from) || (options.until && time > options.until)) {
317
+ if ((options.from && time < options.from) ||
318
+ (options.until && time > options.until) ||
319
+ (options.level && options.level !== log.level)) {
281
320
  return;
282
321
  }
283
322
 
@@ -1,73 +1,120 @@
1
- declare module "winston-daily-rotate-file" {
2
- import * as Transport from "winston-transport";
3
-
4
- namespace DailyRotateFile {
5
- interface DailyRotateFileTransportOptions extends Transport.TransportStreamOptions {
6
- json?: boolean;
7
- eol?: string;
8
-
9
- /**
10
- * A string representing the moment.js date format to be used for rotating. The meta characters used in this string will dictate the frequency of the file rotation. For example, if your datePattern is simply 'HH' you will end up with 24 log files that are picked up and appended to every day. (default 'YYYY-MM-DD')
11
- */
12
- datePattern?: string;
13
-
14
- /**
15
- * A boolean to define whether or not to gzip archived log files. (default 'false')
16
- */
17
- zippedArchive?: boolean;
18
-
19
- /**
20
- * Filename to be used to log to. This filename can include the %DATE% placeholder which will include the formatted datePattern at that point in the filename. (default: 'winston.log.%DATE%)
21
- */
22
- filename?: string;
23
-
24
- /**
25
- * The directory name to save log files to. (default: '.')
26
- */
27
- dirname?: string;
28
-
29
- /**
30
- * Write directly to a custom stream and bypass the rotation capabilities. (default: null)
31
- */
32
- stream?: NodeJS.WritableStream;
33
-
34
- /**
35
- * Maximum size of the file after which it will rotate. This can be a number of bytes, or units of kb, mb, and gb. If using the units, add 'k', 'm', or 'g' as the suffix. The units need to directly follow the number. (default: null)
36
- */
37
- maxSize?: string | number;
38
-
39
- /**
40
- * Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null)
41
- */
42
- maxFiles?: string | number;
43
-
44
- /**
45
- * An object resembling https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options indicating additional options that should be passed to the file stream. (default: `{ flags: 'a' }`)
46
- */
47
- options?: string | object;
48
-
49
- /**
50
- * A string representing the name of the name of the audit file. (default: './hash-audit.json' )
51
- */
52
- auditFile?: string
53
-
54
- /**
55
- * A string representing the frequency of rotation. (default: 'custom')
56
- */
57
- frequency?: string
58
- }
59
- }
60
-
61
- interface DailyRotateFileTransportInstance extends Transport {
62
- filename: string;
63
- dirname: string;
64
- logStream: NodeJS.WritableStream;
65
- options: DailyRotateFile.DailyRotateFileTransportOptions;
66
-
67
- new (options?: DailyRotateFile.DailyRotateFileTransportOptions): DailyRotateFileTransportInstance;
68
- }
69
-
70
- const DailyRotateFile: DailyRotateFileTransportInstance;
71
-
72
- export = DailyRotateFile;
1
+ import TransportStream = require("winston-transport");
2
+
3
+ // referenced from https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist
4
+ type RequireOnlyOne<T, Keys extends keyof T = keyof T> =
5
+ Pick<T, Exclude<keyof T, Keys>>
6
+ & {
7
+ [K in Keys]-?:
8
+ Pick<T, K>
9
+ & Partial<Record<Exclude<Keys, K>, undefined>>
10
+ }[Keys];
11
+
12
+ // merging into winston.transports
13
+ declare module 'winston/lib/winston/transports' {
14
+ interface Transports {
15
+ DailyRotateFile: typeof DailyRotateFile;
16
+ DailyRotateFileTransportOptions: DailyRotateFile.DailyRotateFileTransportOptions;
17
+ }
73
18
  }
19
+
20
+ declare namespace DailyRotateFile {
21
+ type DailyRotateFileTransportOptions = RequireOnlyOne<GeneralDailyRotateFileTransportOptions, 'filename' | 'stream'>;
22
+
23
+ interface GeneralDailyRotateFileTransportOptions extends TransportStream.TransportStreamOptions {
24
+ json?: boolean;
25
+ eol?: string;
26
+
27
+ /**
28
+ * A string representing the moment.js date format to be used for rotating. The meta characters used in this string will dictate the frequency of the file rotation. For example, if your datePattern is simply 'HH' you will end up with 24 log files that are picked up and appended to every day. (default 'YYYY-MM-DD')
29
+ */
30
+ datePattern?: string;
31
+
32
+ /**
33
+ * A boolean to define whether or not to gzip archived log files. (default 'false')
34
+ */
35
+ zippedArchive?: boolean;
36
+
37
+ /**
38
+ * Filename to be used to log to. This filename can include the %DATE% placeholder which will include the formatted datePattern at that point in the filename. (default: 'winston.log.%DATE%)
39
+ */
40
+ filename?: string;
41
+
42
+ /**
43
+ * The directory name to save log files to. (default: '.')
44
+ */
45
+ dirname?: string;
46
+
47
+ /**
48
+ * Write directly to a custom stream and bypass the rotation capabilities. (default: null)
49
+ */
50
+ stream?: NodeJS.WritableStream;
51
+
52
+ /**
53
+ * Maximum size of the file after which it will rotate. This can be a number of bytes, or units of kb, mb, and gb. If using the units, add 'k', 'm', or 'g' as the suffix. The units need to directly follow the number. (default: null)
54
+ */
55
+ maxSize?: string | number;
56
+
57
+ /**
58
+ * Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null)
59
+ */
60
+ maxFiles?: string | number;
61
+
62
+ /**
63
+ * An object resembling https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options indicating additional options that should be passed to the file stream. (default: `{ flags: 'a' }`)
64
+ */
65
+ options?: string | object;
66
+
67
+ /**
68
+ * A string representing the name of the name of the audit file. (default: './hash-audit.json')
69
+ */
70
+ auditFile?: string;
71
+
72
+ /**
73
+ * A string representing the frequency of rotation. (default: 'custom')
74
+ */
75
+ frequency?: string;
76
+
77
+ /**
78
+ * A boolean whether or not to generate file name from "datePattern" in UTC format. (default: false)
79
+ */
80
+ utc?: boolean;
81
+
82
+ /**
83
+ * A string representing an extension to be added to the filename, if not included in the filename property. (default: '')
84
+ */
85
+ extension?: string;
86
+
87
+ /**
88
+ * Create a tailable symlink to the current active log file. (default: false)
89
+ */
90
+ createSymlink?: boolean;
91
+
92
+ /**
93
+ * The name of the tailable symlink. (default: 'current.log')
94
+ */
95
+ symlinkName?: string;
96
+
97
+ /**
98
+ * Watch the current file being written to and recreate it in case of accidental deletion. (default: FALSE)
99
+ */
100
+ watchLog?: boolean;
101
+
102
+ handleRejections?: boolean;
103
+
104
+ /**
105
+ * Use specified hashing algorithm for audit. (default: 'sha256')
106
+ */
107
+ auditHashType?: string;
108
+ }
109
+ }
110
+
111
+ declare class DailyRotateFile extends TransportStream {
112
+ filename: string;
113
+ dirname: string;
114
+ logStream: NodeJS.WritableStream;
115
+ options: DailyRotateFile.DailyRotateFileTransportOptions;
116
+
117
+ constructor(options?: DailyRotateFile.DailyRotateFileTransportOptions);
118
+ }
119
+
120
+ export = DailyRotateFile;
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "name": "winston-daily-rotate-file",
3
- "version": "3.10.0",
3
+ "version": "4.7.1",
4
4
  "description": "A transport for winston which logs to a rotating file each day.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "engines": {
8
- "node": ">=6"
8
+ "node": ">=8"
9
9
  },
10
10
  "scripts": {
11
- "test": "mocha && eslint .",
12
- "preversion": "npm test",
13
- "postversion": "git push && git push --tags && npm publish"
11
+ "test": "mocha --ignore **/*.worker.js && eslint ."
14
12
  },
15
13
  "repository": {
16
14
  "type": "git",
@@ -27,28 +25,31 @@
27
25
  "bugs": {
28
26
  "url": "https://github.com/winstonjs/winston-daily-rotate-file/issues"
29
27
  },
28
+ "files": [
29
+ "daily-rotate-file.js",
30
+ "index.js",
31
+ "index.d.ts"
32
+ ],
30
33
  "homepage": "https://github.com/winstonjs/winston-daily-rotate-file#readme",
31
34
  "peerDependencies": {
32
- "winston": "^2 || ^3"
35
+ "winston": "^3"
33
36
  },
34
37
  "devDependencies": {
35
38
  "chai": "4.2.0",
36
- "eslint": "^6.0.1",
37
- "eslint-config-xo": "^0.26.0",
38
- "mocha": "^6.1.4",
39
- "moment": "^2.24.0",
40
- "rimraf": "2.6.3"
39
+ "eslint": "^6.8.0",
40
+ "eslint-plugin-node": "^11.1.0",
41
+ "mocha": "^7.2.0",
42
+ "rimraf": "^3.0.2",
43
+ "threads": "^1.7.0"
41
44
  },
42
45
  "dependencies": {
43
- "file-stream-rotator": "^0.4.1",
44
- "object-hash": "^1.3.0",
45
- "semver": "^6.2.0",
46
+ "file-stream-rotator": "^0.6.1",
47
+ "object-hash": "^2.0.1",
46
48
  "triple-beam": "^1.3.0",
47
- "winston-compat": "^0.1.4",
48
- "winston-transport": "^4.2.0"
49
+ "winston-transport": "^4.4.0"
49
50
  }
50
51
 
51
- ,"_resolved": "https://registry.npmjs.org/winston-daily-rotate-file/-/winston-daily-rotate-file-3.10.0.tgz"
52
- ,"_integrity": "sha512-KO8CfbI2CvdR3PaFApEH02GPXiwJ+vbkF1mCkTlvRIoXFI8EFlf1ACcuaahXTEiDEKCii6cNe95gsL4ZkbnphA=="
53
- ,"_from": "winston-daily-rotate-file@3.10.0"
52
+ ,"_resolved": "https://registry.npmjs.org/winston-daily-rotate-file/-/winston-daily-rotate-file-4.7.1.tgz"
53
+ ,"_integrity": "sha512-7LGPiYGBPNyGHLn9z33i96zx/bd71pjBn9tqQzO3I4Tayv94WPmBNwKC7CO1wPHdP9uvu+Md/1nr6VSH9h0iaA=="
54
+ ,"_from": "winston-daily-rotate-file@4.7.1"
54
55
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "populist",
2
+ "extends": "@dabh/eslint-config-populist",
3
3
  "rules": {
4
4
  "one-var": ["error", { var: "never", let: "never", const: "never" }],
5
5
  "strict": 0