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

pixl-logger

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pixl-logger - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

33

logger.js
// Generic Logger Class for Node.JS
// Copyright (c) 2012 - 2017 Joseph Huckaby and PixlCore.com
// Copyright (c) 2012 - 2018 Joseph Huckaby and PixlCore.com
// Released under the MIT License

@@ -73,9 +73,10 @@

// import args into object
for (var key in args) this.args[key] = args[key];
// for (var key in dargs) this.args[key] = dargs[key];
for (var key in this.args) {
if (!(key in args)) args[key] = this.args[key];
}
// set automatic column values
this.args.hires_epoch = now.getTime() / 1000;
this.args.epoch = Math.floor( this.args.hires_epoch );
this.args.date = dargs.yyyy_mm_dd.replace(/\//g, '-') + ' ' + dargs.hh_mi_ss;
args.hires_epoch = now.getTime() / 1000;
args.epoch = Math.floor( args.hires_epoch );
args.date = dargs.yyyy_mm_dd.replace(/\//g, '-') + ' ' + dargs.hh_mi_ss;

@@ -86,3 +87,3 @@ // populate columns

var col = this.columns[idx];
var val = this.args[col];
var val = args[col];

@@ -101,3 +102,3 @@ if ((typeof(val) == 'undefined') || (val === null) || !val.toString) val = '';

// compose log row
var line = this.serializer ? this.serializer(cols, this.args) : ('[' + cols.join('][') + "]\n");
var line = this.serializer ? this.serializer(cols, args) : ('[' + cols.join('][') + "]\n");
this.lastRow = line;

@@ -108,24 +109,24 @@

if (this.pather) {
path = this.pather( path, this.args );
path = this.pather( path, args );
}
else if (path.indexOf('[') > -1) {
path = Tools.substitute( path, this.args );
path = Tools.substitute( path, args );
}
// append to log
if (this.args.sync) fs.appendFileSync(path, line);
if (args.sync) fs.appendFileSync(path, line);
else fs.appendFile(path, line, function() {});
// echo to console if desired
if (this.args.echo) {
if (args.echo) {
if (this.echoer) {
if (typeof(this.echoer) == 'function') {
this.echoer( line, cols, this.args );
this.echoer( line, cols, args );
}
else if (typeof(this.echoer) == 'string') {
if (this.args.sync) fs.appendFileSync(this.echoer, line);
if (args.sync) fs.appendFileSync(this.echoer, line);
else fs.appendFile(this.echoer, line, function() {});
}
}
else if (this.args.color) {
else if (args.color) {
var ccols = [];

@@ -148,3 +149,3 @@ var nclrs = this.columnColors.length;

// emit row as an event
this.emit( 'row', line, cols, this.args );
this.emit( 'row', line, cols, args );
},

@@ -151,0 +152,0 @@

{
"name": "pixl-logger",
"version": "1.0.12",
"version": "1.0.13",
"description": "A simple logging class which generates [bracket][delimited] log columns.",

@@ -21,6 +21,6 @@ "author": "Joseph Huckaby <jhuckaby@gmail.com>",

"dependencies": {
"async": "^1.0.0",
"mkdirp": "^0.5.1 || ^1.0.0",
"glob": "^5.0.0",
"chalk": "^1.1.1",
"async": "2.6.0",
"mkdirp": "0.5.1",
"glob": "5.0.15",
"chalk": "2.4.1",
"pixl-class": "^1.0.0",

@@ -27,0 +27,0 @@ "pixl-tools": "^1.0.0"

@@ -54,2 +54,4 @@ # Overview

Note that when you pass arguments to `print()` they are not saved for subsequent calls. They are only used for that one log row. You need to call `set()` to make them stick.
You can also fetch arg values using `get()`. Pass in a key to fetch one arg, or omit to get the entire `args` object back.

@@ -332,3 +334,3 @@

Copyright (c) 2015 - 2017 Joseph Huckaby
Copyright (c) 2015 - 2018 Joseph Huckaby

@@ -335,0 +337,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

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