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

seneca

Package Overview
Dependencies
Maintainers
5
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seneca - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

13

CHANGES.md

@@ -0,1 +1,13 @@

## 3.1 2016-09-16
* Correct issue with log handlers not working via command line
* Extracted out log handling into seneca-log-filters for ease of reuse in custom loggers
* Replaced the default log handler's filter logic with seneca-log-filters
* Bumped patrun to correct incorrect matches with partial patterns due to missing catchall
* Added error handling example in docs/examples/error-handling.js.
* Changed boot log message from 'hello' to 'seneca-started'.
* Updated salestax examples to work correctly.
* Removed old legacy parsing handlers as they caused crashes
* Added testable transport links
## 3.0: 2016-08-26

@@ -25,2 +37,3 @@

* Removed seneca-basic as a default loaded plugin. Removed related tests. Removed from package.
* Removed seneca-repl as a default loaded plugin. Removed related tests. Removed from package.
* Removed seneca-parambulator as a default loaded plugin. Removed related tests. Removed from package.

@@ -27,0 +40,0 @@ * Removed parambulator as a default loaded plugin. Removed related tests. Removed from package.

73

lib/logging.js
/* Copyright (c) 2016 Richard Rodger and other contributors, MIT License */
'use strict'
var LogFilter = require('seneca-log-filter')
var _ = require('lodash')
var Patrun = require('patrun')
var loglevels = ['debug', 'info', 'warn', 'error', 'fatal']
module.exports = logging
function logging (options) {

@@ -20,56 +14,33 @@ // Everything is in preload as logging plugins are

logging.preload = function () {
var seneca = this
var logrouter
var so = seneca.options()
var logspec = so.log.basic || so.log
// Default logging level is info+
if (0 === _.keys(logspec).length) {
logspec = {level: 'info+'}
if (_.isString(logspec)) {
logspec = {level: logspec}
}
// Some convenience shortcuts
else if ('silent' === logspec) {
logspec = {level: 'none'}
logspec.aliases = {
'quiet': {
handled: true,
handler: function () { return ['none'] }
},
'any': {
handled: true,
handler: function () { return ['debug+'] }
},
'print': {
handled: true,
handler: function () { return ['debug+'] }
},
'standard': {
handled: true,
handler: function () { return ['info+'] }
}
}
else if ('test' === logspec) {
logspec = {level: 'error+'}
}
// level property needs to be set to see any logs
if (null !== logspec.level && 'none' !== logspec.level) {
// this should be optional, need to allow for pure pass-through
logrouter = Patrun({ gex: true })
var logrouter = LogFilter(logspec)
var logpatterns = _.isArray(logspec) ? logspec : [logspec]
for (var i = 0; i < logpatterns.length; ++i) {
var logpat = logpatterns[i]
var sublogpats = []
// level+ syntax: info+ means info and above: info, warn, error, fatal
if (logpat.level && logpat.level.match(/\+$/)) {
var level = logpat.level.substring(0, logpat.level.length - 1)
if (-1 < loglevels.indexOf(level)) {
var levels = [].concat(loglevels.slice(loglevels.indexOf(level)))
for (var k = 0; k < levels.length; ++k) {
sublogpats.push(_.extend({}, logpat, {level: levels[k]}))
}
}
}
else {
sublogpats.push(logpat)
}
for (var j = 0; j < sublogpats.length; ++j) {
logrouter.add(sublogpats[j], true)
}
}
}
var logger = function (seneca, data) {
if (logrouter && logrouter.find(data)) {
if (logrouter && logrouter(data)) {
console.log(JSON.stringify(data))

@@ -76,0 +47,0 @@ }

@@ -9,3 +9,2 @@ /* Copyright (c) 2014-2016 Richard Rodger and other contributors, MIT License */

var Minimist = require('minimist')
var Legacy = require('./legacy')
var Common = require('./common')

@@ -81,9 +80,28 @@

sourcemap.argv.log = sourcemap.argv.log || {}
sourcemap.argv.log.map = sourcemap.argv.log.map || []
Legacy.parse_command_line(argv.seneca.log,
sourcemap.argv.log,
{ shortcut: true })
parse_command_line(argv.seneca.log, sourcemap.argv)
}
}
function parse_command_line (spec, parsedSpec) {
var logSpec = _.isArray(spec) ? spec[0] : spec
if (_.isString(logSpec)) {
try {
parsedSpec.log = Jsonic(logSpec)
}
catch (e) {
parsedSpec.log = {}
}
return
}
if (_.isObject(logSpec)) {
parsedSpec.log = {}
var logType = Object.keys(logSpec.level)
if (logType.length > 0) {
parsedSpec.log = { level: logType[0] }
}
}
}
function set_options (input) {

@@ -90,0 +108,0 @@ if (input == null) throw error('no_options')

{
"name": "seneca",
"description": "A Microservices Framework for Node.js",
"version": "3.0.0",
"version": "3.1.0",
"license": "MIT",

@@ -88,7 +88,8 @@ "homepage": "http://senecajs.org",

"norma": "0.3.0",
"patrun": "0.5.0",
"patrun": "0.5.1",
"rolling-stats": "0.1.1",
"semver": "5.3.0",
"seneca-transport": "2.1.0",
"use-plugin": "0.3.1"
"use-plugin": "0.3.1",
"seneca-log-filter": "0.1.0"
},

@@ -95,0 +96,0 @@ "devDependencies": {

@@ -380,3 +380,3 @@ ![Logo][]

[Npm]: https://www.npmjs.com/package/seneca
[Org]: https://github.com/senecajs/issues
[Org]: http://senecajs.org/
[Pull]: https://github.com/senecajs/seneca/pulls

@@ -383,0 +383,0 @@ [Sponsor]: http://nearform.com

@@ -187,3 +187,3 @@ /* Copyright (c) 2010-2016 Richard Rodger and other contributors, MIT License */

seneca.log.info({kind: 'notice', notice: 'hello'})
seneca.log.info({kind: 'notice', notice: 'seneca started'})

@@ -190,0 +190,0 @@ // The 'internal' key of options is reserved for objects and functions

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