Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bunyan

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunyan - npm Package Compare versions

Comparing version 0.21.4 to 0.22.0

6

CHANGES.md

@@ -9,2 +9,8 @@ # bunyan Changelog

## bunyan 0.22.0
- [issue #104] `log.reopenFileStreams()` convenience method to be used with
external log rotation.
## bunyan 0.21.4

@@ -11,0 +17,0 @@

40

lib/bunyan.js

@@ -7,3 +7,3 @@ /*

var VERSION = '0.21.4';
var VERSION = '0.22.0';

@@ -512,2 +512,40 @@ // Bunyan log format version. This becomes the 'v' field on all log records.

/**
* A convenience method to reopen 'file' streams on a logger. This can be
* useful with external log rotation utilities that move and re-open log files
* (e.g. logrotate on Linux, logadm on SmartOS/Illumos). Those utilities
* typically have rotation options to copy-and-truncate the log file, but
* you may not want to use that. An alternative is to do this in your
* application:
*
* var log = bunyan.createLogger(...);
* ...
* process.on('SIGUSR2', function () {
* log.reopenFileStreams();
* });
* ...
*
* See <https://github.com/trentm/node-bunyan/issues/104>.
*/
Logger.prototype.reopenFileStreams = function () {
var self = this;
self.streams.forEach(function (s) {
if (s.type === 'file') {
if (s.stream) {
// Not sure if typically would want this, or more immediate
// `s.stream.destroy()`.
s.stream.end();
s.stream.destroySoon();
delete s.stream;
}
s.stream = fs.createWriteStream(s.path,
{flags: 'a', encoding: 'utf8'});
s.stream.on('error', function (err) {
self.emit('error', err, s);
});
}
});
};
/* BEGIN JSSTYLED */

@@ -514,0 +552,0 @@ /**

2

package.json
{
"name": "bunyan",
"version": "0.21.4",
"version": "0.22.0",
"description": "a JSON Logger library for node.js services",

@@ -5,0 +5,0 @@ "author": "Trent Mick <trentm@gmail.com> (http://trentm.com)",

@@ -53,3 +53,3 @@ Bunyan is **a simple and fast JSON logging library** for node.js services:

- custom rendering of logged objects with ["serializers"](#serializers)
- [Dtrace support](#dtrace-support)
- [Runtime log snooping via Dtrace support](#dtrace-support)

@@ -724,3 +724,20 @@

**Note on log rotation**: Often you may be using external log rotation utilities
like `logrotate` on Linux or `logadm` on SmartOS/Illumos. In those cases, unless
your are ensuring "copy and truncate" sematics (via `copytruncate` with
logrotate or `-c` with logadm) then the fd for your 'file' stream will change.
You can tell bunyan to reopen the file stream with code like this in your
app:
var log = bunyan.createLogger(...);
...
process.on('SIGUSR2', function () {
log.reopenFileStreams();
});
where you'd configure your log rotation to send SIGUSR2 (or some other signal)
to your process. Any other mechanism to signal your app to run
`log.reopenFileStreams()` would work as well.
## stream type: `raw`

@@ -787,3 +804,3 @@

# DTrace support
# Runtime log snooping via DTrace

@@ -790,0 +807,0 @@ On systems that support DTrace (e.g., MacOS, FreeBSD, illumos derivatives

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc