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

pino-roll

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-roll - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

10

lib/utils.js

@@ -87,2 +87,11 @@ 'use strict'

async function getFileSize (filePath) {
try {
const fileStats = await stat(filePath)
return fileStats.size
} catch {
return 0
}
}
async function detectLastNumber (fileVal, time = null) {

@@ -138,3 +147,4 @@ const fileName = getFileName(fileVal)

getFileName,
getFileSize,
validateLimitOptions
}

2

package.json
{
"name": "pino-roll",
"version": "1.0.0",
"version": "1.0.1",
"description": "A Pino transport that automatically rolls your log files",

@@ -5,0 +5,0 @@ "main": "pino-roll.js",

@@ -11,2 +11,3 @@ 'use strict'

getNext,
getFileSize,
validateLimitOptions

@@ -80,3 +81,3 @@ } = require('./lib/utils')

const createdFileNames = [fileName]
let currentSize = 0
let currentSize = await getFileSize(fileName)
const maxSize = parseSize(size)

@@ -99,3 +100,3 @@

currentSize = 0
// delay to let the our destination finish its write
// delay to let the destination finish its write
setTimeout(roll, 0)

@@ -102,0 +103,0 @@ }

@@ -10,2 +10,3 @@ 'use strict'

buildFileName,
getFileSize,
detectLastNumber,

@@ -57,3 +58,3 @@ getNext,

test('getNext()', async ({ same, throws }) => {
test('getNext()', async ({ same }) => {
const today = new Date()

@@ -82,2 +83,19 @@

test('getFileSize()', async ({ test, beforeEach }) => {
const folder = join('logs', 'utils')
beforeEach(() => cleanAndCreateFolder(folder))
test('given an existing file', async ({ equal }) => {
const fileName = join(folder, 'file.log')
await writeFile(fileName, '123')
equal(await getFileSize(fileName), 3, 'detects size of existing file')
})
test('given a non existing file', async ({ equal }) => {
const fileName = join(folder, 'file.log')
equal(await getFileSize(fileName), 0, 'set current size to 0 with non existing file')
})
})
test('detectLastNumber()', async ({ test, beforeEach }) => {

@@ -84,0 +102,0 @@ const folder = join('logs', 'utils')

@@ -126,3 +126,3 @@ 'use strict'

})
for (let i = 1; i <= 7; i++) {
for (let i = 1; i <= 6; i++) {
stream.write(`logged message #${i}\n`)

@@ -138,10 +138,9 @@ await sleep(20)

ok(content.includes('#3'), 'second file contains third log')
ok(content.includes('#4'), 'second file contains fourth log')
await stat(`${file}.4`)
content = await readFile(`${file}.4`, 'utf8')
ok(content.includes('#4'), 'third file contains fourth log')
ok(content.includes('#5'), 'third file contains fifth log')
ok(content.includes('#6'), 'third file contains sixth log')
await stat(`${file}.5`)
content = await readFile(`${file}.5`, 'utf8')
ok(content.includes('#7'), 'fourth file contains seventh log')
ok(content.includes('#6'), 'fourth file contains sixth log')
await rejects(stat(`${file}.2`), 'resumed file was deleted')

@@ -148,0 +147,0 @@ await rejects(stat(`${file}.6`), 'no other files created')

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