New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

log-timed

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

log-timed

Lightweight logging with timestamps, colors and file support

latest
npmnpm
Version
1.1.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

log-timed

Lightweight logging with timestamps, colors and file support.

Uses chalk for colors.
File writing is asynchronous and doesn't block process.

Install

npm install log-timed

Usage

import { casual as log } from 'log-timed'

log('Simple message')
log.file('Log to console and file')
log.error('Error occurred')
log.multiline({ user: 'John', data: [1, 2, 3] })
log.compact('Line 1\nLine 2\nLine 3')

Custom logger

import createLogger from 'log-timed'

const log = createLogger({
    useDate: true, // show date
    useMs: true, // show milliseconds
    colorLeft: 'blue', // timestamp color
    file: 'app_', // file prefix
})

log('Custom logging')

Methods

Basic:

  • log() - standard logging
  • .log(...args) - multiple arguments like console.log
  • .logFile(...args) - multiple arguments with file write
  • .file() - log to console and file
  • .fileOnly() - log to file only
  • .multiline() - multiline object output
  • .compact() - compress newlines to single line
  • .rewrite() - rewrite last console line
  • .clear() - clear terminal

Event logging:

  • .success() - success operations (green)
  • .info() - informational messages (cyan)
  • .warn() - warnings (yellow)
  • .error() - errors (red)
  • .debug() - debug info (dimmed)

Each event method has a *File() version for writing to file with corresponding prefix (e.g., success_, info_). To write to file without prefix, use method(data, { file: true }).

Presets

import { free, simple, casual, full, iso } from 'log-timed'

free('No timestamps') // No timestamps
simple('With time') // [03:00:00] With time
casual('With milliseconds') // [13:37:42.999] With milliseconds
full('Full date and time') // [2025.12.31 23:59:59.999] Full date and time
iso('ISO format') // [2025-10-21T01:21:00.000Z] ISO format

File logging

Logs are saved to ./logs/ directory with YYYY.MM.DD.log naming by default.

// Default file: ./logs/2025.11.07.log
log.file('message')
log('message', { file: true })

// With prefix: ./logs/error_2025.11.07.log
log('message', { file: 'error_' })
log.errorFile('message')

// Custom filename: ./logs/app.log
log('message', { file: 'app.log' })

// Custom path: ./custom/path/app.log
log('message', { file: './custom/path/app.log' })

// File only (no console output)
log('message', { fileOnly: true })

Multiline formatting

// Objects
log({ data: 'test' }) // {"data":"test"}
log({ data: 'test' }, { multiline: true }) // pretty JSON (4 spaces)
log({ data: 'test' }, { multiline: 2 }) // pretty JSON (2 spaces)

// Compact with separators
log('line1\nline2', { multiline: ' ' }) // "line1 line2"
log('line1\nline2', { multiline: '' }) // "line1line2"
log('line1\nline2', { multiline: ', ' }) // "line1, line2"

Config

  • useDate - show date
  • useMs - show milliseconds
  • colorLeft - timestamp color
  • colorRight - message color
  • colorMs - milliseconds color (default: 'gray')
  • color - set both colorLeft and colorRight
  • file - file prefix or boolean
  • leftFn - custom function for left part

Keywords

log

FAQs

Package last updated on 15 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts