Socket
Socket
Sign inDemoInstall

logks

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logks

Nodejs logger


Version published
Maintainers
1
Created
Source

logx πŸ“

Simple logger module

var log = new Logx({
	level: 'debug',
	color: true,
});

log.error('System', 'Component', 'Message')

2017-11-30 20:03:35 [System] [Component] Message

Config

OptionDescriptionDefault
colorsShould use colorsfalse
levelLog level. Look levelsinfo
dateShould every message line prefixed with date or nottrue
levelsLevels description and priorities. Index in table is priority, and value is a array where 1st element is name of level and second is a coloring function.
[
    ['silly', chalk.white],
    ['debug', chalk.green],
    ['info', chalk.magenta],
    ['warning', chalk.yellow],
    ['error', chalk.red],
    ['special', chalk.cyan.underline],
    ['critical', chalk.red.underline.bold],
]

json

json.maxLengthMax length of lines in json message. JSON will be stringified counting this option.64
json.maxRowLengthMax line length in json message, if symbols count exceeded it will be striped by ...process.stdout.columns - 5
json.defaultColorDefault coloring function of messages in jsonchalk.rgb(167, 101, 121)

Levels

Levels are prioritized entities to separate log messages by semantic. You can cover yout code with logging different depth and if you want to run your app on production mode you will not see debug log level. These are default log levels of LogX:

  • silly: chalk.white
  • debug: chalk.green
  • info: chalk.magenta
  • warning: chalk.yellow
  • error: chalk.red
  • special: chalk.cyan.underline
  • critical: chalk.red.underline.bold

json

Every level logging function has .json property.

logger.warning.json('API', 'Payments', 'v3.2', 'Health check failed', {"reward":128.23,"instances":2,"availableApis":[{"host":"127.0.0.1","port":8888},{"host":"127.0.0.1","port":8889}],"healthCheck":false})

Will produce:

2018-09-01 10:58:16 [API] [Payments] (v3.2) Health check failed
2018-09-01 10:58:16 ───┬───────────────────────────────────────────────────────────────────
2018-09-01 10:58:16 0  β”‚ {
2018-09-01 10:58:16 1  β”‚   "reward": 128.23,
2018-09-01 10:58:16 2  β”‚   "instances": 2,
2018-09-01 10:58:16 3  β”‚   "availableApis": [
2018-09-01 10:58:16 4  β”‚     { "host": "127.0.0.1", "port": 8888 },
2018-09-01 10:58:16 5  β”‚     { "host": "127.0.0.1", "port": 8889 }
2018-09-01 10:58:16 6  β”‚   ],
2018-09-01 10:58:16 7  β”‚   "healthCheck": false
2018-09-01 10:58:16 8  β”‚ }
2018-09-01 10:58:16 ───┴───────────────────────────────────────────────────────────────────

FAQs

Package last updated on 01 Sep 2018

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

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