winstonjs / winston-syslog Goto Github PK
View Code? Open in Web Editor NEWA syslog transport for winston
Home Page: http://github.com/winstonjs/winston-syslog
License: MIT License
A syslog transport for winston
Home Page: http://github.com/winstonjs/winston-syslog
License: MIT License
This rule is never successfully matched because winston-syslog does not produce a valid format that can be filtered by program name:
/etc/rsyslog.d/01-app.conf
if $programname == 'app' then {
action(type="omfile" file="/var/log/app.log")
~ stop
}
Here is an example log message showing up in /var/log/syslog that is not being properly filtered. Note the extraneous localhost
. I am pretty sure that this is what is screwing things up.
Jan 3 19:54:29 tegra-ubuntu localhost app[30934]: info: interface-proxy.js: Updating the interface proxy
Winston supports a formatter
function for formatting the log record (winstonjs/winston@a34f7d2)
This would be handy for the syslog transport too.
Hi, I would like to log message with JSON line format.
Not like
appName: [pid] {"JSON": "FORMAT"}
But
{"JSON": "FORMAT"}
I read the doc and the code, and if appName
is not specified, process.title
is used.
https://github.com/squeeks/glossy skips setting appName
and pid
if appName
is falsy value.
The line
this.appName = options.appName || options.app_name || process.title;
sets process.title
if appName
or app_name
is set. I need to set process.title
, but not for logging. Can you change the line or any options not to set appName
.
If you need PR. I will PR, but can you give me idea to fix this?
In options
, include:
protocol: "unix",
path: "/dev/log", // For Linux. /var/run/log on BSD/OSX?
A sweet advantage of this approach is that it works without forcing the user to configure his syslog instance.
When logging via unix datagram sockets, you have to specify a path to write the logs to. It would be a great advantage if the library could find the system default syslog pipe by default.
Per my cursory investigation, this seems to be /dev/log
in Linux, /var/run/log
in BSD and /var/run/syslog
in OSX. I would hope there is a reliable way to determine this at runtime.
I recently posted this question to StackOverflow but I am hoping for a faster response here.
In short I don't see anything logged into the Console app on OSX.
const winston = require('winston');
require('winston-syslog').Syslog; // eslint-disable-line
const env = process.env.NODE_ENV;
let syslogConfig = {
"host": "localhost",
"port": 514,
"protocol": "unix",
"path": "/var/run/syslog"
};
const logger = new winston.Logger({
levels: winston.config.syslog.levels,
colors: winston.config.syslog.colors
});
logger.add(winston.transports.Syslog, syslogConfig);
logger.add(winston.transports.Console, {
json: false,
colorize: true,
timestamp: true
});
// this should be logged and visible from Console app...
logger.error('Hello, world!');
module.exports = logger;
Are my configuration settings somehow incorrect? I get no errors in my terminal.
When you log multiple messages and have it setup to use TCP when syslog outputs it is in the same line.
To work around this issue we had to add a "\n" to the end of the message so syslog treats it as a separate log message.
e.g:
info('test 1');
info('test 2');
Will show up in syslog as:
2015-06-16T15:27:47-06:00 xxxxxxx xxxxxx[11917]: info: test1<174>Jun 16 15:27:47 xxxxxxxx xxxxxx[11917]: info: test2
My problem is that in GlossyProducer, the generateBSDDate function creates a date like this:
'Aug 4 14:21:20 '
So the day is padded correctly with leading space. This is the format what syslog-ng can parse, BUT this code, wich joins the message array into the message string, cut that leading space from it and ruins the parseable format:
var compiledMessage = msgData.join(' ').replace(/\s+/g, ' ');
Pls produce a fix for that issue.
Thanks in advance!
{protocol: 'unix'} is invalid for
new dgram.Socket(this.protocol);
as outlined in the documentation for node v0.10.20
http://nodejs.org/api/dgram.html#dgram_dgram_createsocket_type_callback
Can you publish a new release to NPM? There appears to be a few issues resolved since the last release.
When I call .close()
on a logger with a syslog transport the following error is thrown:
failed to close logger TypeError: self.socket.close is not a function
at _close (/Users/bart/Documents/Temp/fromMUGit/moodle-integration-33/node_modules/winston-syslog/lib/winston-syslog.js:227:21)
at exports.Syslog.Syslog.close (/Users/bart/Documents/Temp/fromMUGit/moodle-integration-33/node_modules/winston-syslog/lib/winston-syslog.js:236:4)
at /Users/bart/Documents/Temp/fromMUGit/moodle-integration-33/node_modules/winston/lib/winston/logger.js:405:17
at Array.forEach (native)
at exports.Logger.Logger.close (/Users/bart/Documents/Temp/fromMUGit/moodle-integration-33/node_modules/winston/lib/winston/logger.js:402:15)
...
Syslog has the following log level names:
Currently, this transport will not recognize using the names "warn", "err", and "panic". I know it is trying to just have parity with the log levels defined in the winston.config.syslog.levels
object, but I already think that is kind of messed up because that object picks and chooses which log level names to use. For example, it uses "error" instead of "err" but uses the default level names for the rest of the levels.
I think it would be nice for the syslog transport module to allow all of the names above. Of course, the decision is up to the repository maintainers. It doesn't look like we actually use the numerical values corresponding to log level keywords, so the extra keywords could probably just be added in.
Like:
var levels = Object.keys({
debug: 0,
info: 1,
notice: 2,
warning: 3,
warn: 3,
err: 4,
error: 4,
crit: 5,
alert: 6,
emerg: 7,
panic: 7
});
I am having the following error after upgrading to node v0.12.0
/usr/local/bin/node web/server.js
/mypath/node_modules/winston-syslog/node_modules/unix-dgram/node_modules/bindings/bindings.js:83
throw e
^
Error: Module did not self-register.
at Error (native)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at bindings (/mypath/node_modules/winston-syslog/node_modules/unix-dgram/node_modules/bindings/bindings.js:76:44)
at Object. (/mypath/node_modules/winston-syslog/node_modules/unix-dgram/lib/unix_dgram.js:4:34)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
Process finished with exit code 1
Can somebody with permissions publish the last 2 versions to npm?. Thanks!
/cc @indexzero @winstonjs/core
Currently if meta has circular references, logging breaks with some nasty infinite recursion. I think this is probably worth fixing at least for the fact that logging shouldn't bring down an application, no matter how dumb the developer was for passing in a self-referencing object (and yes, I was that dumb).
I'd just do something like this at the top of Syslog.prototype.log():
if (meta){
try {
meta = JSON.stringify(data);
} catch(ex){
meta = " NOTE: Could not stringify meta: " + JSON.stringify(ex);
}
}
...but you might have a smarter way. It seems like the problem could manifest in winston.clone(), so you might want to fix this in winston itself instead, but this fix makes the otherwise unsafe stringify() on 119 safe too.
Hi,
I was trying to use the syslog plugin with the winston logger. When i tried to initialize with default parameters, it tries to connect to the udp port 514.
Here i get a Permission denied exception. When i run the node server with sudo mode, it doesn't throw an error, but the connection doesn't get established, so all my messages are queued in the buffer.
I am doing this in my mac. Is there some thing i should be doing which i am missing.
I tried using unix_dgram protocol , but you don't have a option to specify the pid file name in the option list, which is required by the dgram library of node.
Thanks.
Somewhat a follow-on to #87, which was closed.
Setting the syslog log levels with the param on createLogger, as is appropriate for Winston 3 doesn't seem to be working quite as expected. I made a little test program:
const { createLogger, format, transports, config, } = require('winston');
require('winston-syslog').Syslog;
const logger = createLogger({
levels: config.syslog,
format: format.simple(),
transports: [
new transports.Console(),
new transports.Syslog({
type: '5424',
protocol: 'unix',
path: '/var/run/syslog',
})
]
});
logger.notice(`Current Testing Time is: ${new Date()}`)
logger.error("Here is a test error message")
When I run that with Node 8, Winston 3.0.0-rc1, I get this error:
TypeError: logger.notice is not a function
Which implies that it's not getting the right levels, which seems odd, since winston.config.syslog
logs out as:
{ levels:
{ emerg: 0,
alert: 1,
crit: 2,
error: 3,
warning: 4,
notice: 5,
info: 6,
debug: 7 },
colors:
{ emerg: 'red',
alert: 'yellow',
crit: 'red',
error: 'red',
warning: 'red',
notice: 'yellow',
info: 'green',
debug: 'blue' } }
Now, if I swap the Logger constructor to:
levels: config.syslog.levels,
We get further, but now I get this error:
notice: Current Testing Time is: Tue Nov 07 2017 08:59:07 GMT-0600 (CST) {}
/Users/perry.shuman/Code/temp/log_test/node_modules/winston-syslog/lib/winston-syslog.js:126
return callback(new Error('Cannot log unknown syslog level: ' + level));
^
TypeError: callback is not a function
at exports.Syslog.Syslog.log (/Users/perry.shuman/Code/temp/log_test/node_modules/winston-syslog/lib/winston-syslog.js:126:12)
at exports.Syslog.TransportStream._write (/Users/perry.shuman/Code/temp/log_test/node_modules/winston-transport/index.js:88:17)
at doWrite (_stream_writable.js:387:12)
at writeOrBuffer (_stream_writable.js:373:5)
at exports.Syslog.Writable.write (_stream_writable.js:290:11)
at DerivedLogger.ondata (_stream_readable.js:639:20)
at emitOne (events.js:121:20)
at DerivedLogger.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
Which looks like winston-syslog isn't reading the level that's passed in as a valid level, since you shouldn't be able to get to line 126 without failing this conditional:
if (!~levels.indexOf(level)) {
return callback(new Error('Cannot log unknown syslog level: ' + level));
}
Do you have any plans to add support for TLS connection to remote syslog servers?
We need this for a high compliance environment where all logging is secured.
I don't know whether this still applies to modern Node, but for obscure reasons I'm using 6.11, and winston-syslog when using TCP needs a process.on('exit', ...)
handler (I think in connect()
) that performs ...
if (!this.isDgram) {
this.socket.unref();
this.socket.end();
this.socket.destroy();
}
... otherwise the server side doesn't tear down its side of the TCP connection, and the number of "established" connections showing from the client side increases until such point as the syslog service (or the kernel or something) blocks that client. Effectively, you can DoS yourself if you have lots of short-running Node apps that do syslog over TCP.
Since 1.2.2 the option app_name does not work anymore and is being replaced by process title. We are reverting to 1.2.1 for now.
our code snippet to reproduce the error
var winston = require('winston');
var os = require('os');
require('winston-syslog').Syslog;
var logger = new(winston.Logger)({
transports: [
new winston.transports.Syslog({
host: 'someHost',
protocol: 'udp4',
localhost: os.hostname(),
app_name: 'thisWillBeIgnored'
})
]
});
The library does not expose winston's timestamp option yet. I had a recent failure and realized I couldn't provide a time for my logs.
When we call Syslog.prototype.log
, is there a reason we don't send the msg
, meta
, and level
through the Common.log
function? That would allow us to just accept a lot more formatting options, such as json
, colorize
, prettyPrint
, etc.
This is my winston config:
var winston = require('winston');
var fs = require('fs');
var _ = require('lodash');
winston.emitErrs = true;
var logDir = 'logs';
if (!fs.existsSync(logDir)) {
fs.mkdirSync(logDir);
}
//add custom logging levels
var levels = _.clone(winston.config.syslog.levels);
var colors = _.clone(winston.config.syslog.colors);
levels.request = _.max(levels) + 1;
colors.request = 'blue';
var logger = new winston.Logger({
levels: levels,
colors: colors,
exceptionHandlers: [
new winston.transports.File({filename: 'logs/exceptions.log'})
],
transports: [
new winston.transports.File({
name: 'info-file',
level: 'info',
filename: 'logs/all-logs.log',
json: true,
maxsize: 5242880, //5MB
maxFiles: 5,
colorize: false
}),
new winston.transports.File({
name: 'error-file',
level: 'error',
filename: 'logs/error-logs.log',
json: true,
maxsize: 5242880, //5MB
maxFiles: 5,
colorize: false
}),
new winston.transports.File({
name: 'request-file',
level: 'request',
filename: 'logs/requests.log',
json: true,
maxsize: 5242880, //5MB
maxFiles: 5,
colorize: false
})
],
exitOnError: false
});
module.exports = logger;
I'm trying to log, errors, http-requests, and exceptions to their own files.
However, I see, for example, in error-logs.log (http)requests logs.
Can anybody explain to me what I'm doing wrong?
Hi all, i think that option in Subj should not be a mandatory because local syslog daemon already will set hostname if you send to /dev/log unix domain. if you send messages to remote server it also can determinate name of server by it's ip or log just IP, but since localhost
option is mandatory Syslog message is misconfigured, because it have additional tag into syslog event. Maybe for many of users it is not a problem, but i found it not handy because i should :
i think it is best to have possibility to set option.localhost to false or null
to skip this tag in a syslog event.
I can only get it to work with IPs, but not with DNS names.
Which for us is a huge issue.
It's not possible to use winston-syslog 0.2.3 without fix in master.
https://github.com/indexzero/winston-syslog/blob/master/lib/winston-syslog.js#L125
Please, publish new version as soon as possible.
The documentation and the comments in code mention that the library is compliant with RFC 3164 and RFC 5424. The default value for type in options is 'BSD' which corresponds to RFC 3164 Protocol. What is the value for options.type corresponding to RFC 5424.
Update unix-dgram
version to v2.0.1
or upper. For fix build on Solaris.
PR in unix-dgram
: bnoordhuis/node-unix-dgram#46
Promised by @santigimeno
Thanks!
I get the following error trying to use 2.0.0 with the README.md instructions. Either the instructions need to be updated or there is a syntax error in the new release:
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/share/deathstar/node/modules/logger.js:4:16)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
Error is happening as a result of the require:
1 'use strict';
2
3 const winston = require('winston');
4 require('winston-syslog').Syslog;
5
[email protected] install /myProj/node_modules/winston-syslog/node_modules/unix-dgram
node-gyp rebuild
make: Entering directory /myProj/node_modules/winston-syslog/node_modules/unix-dgram/build' CXX(target) Release/obj.target/unix_dgram/src/unix_dgram.o make: g++: Command not found make: *** [Release/obj.target/unix_dgram/src/unix_dgram.o] Error 127 make: Leaving directory
/myProj/node_modules/winston-syslog/node_modules/unix-dgram/build'
gyp ERR! build error
gyp ERR! stack Error: make
failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Linux 3.13.0-24-generic
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /myProj/node_modules/winston-syslog/node_modules/unix-dgram
gyp ERR! node -v v0.10.39
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the unix-dgram package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls unix-dgram
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.13.0-24-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "winston-syslog" "--save"
npm ERR! cwd /myProj
npm ERR! node -v v0.10.39
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0
Needed sudo apt-get install build-essential g++ in order to install node module.
Seems like this module only works with the latest release candidate Winston v3? winston-transport
is not a dependency of Winston v2.x, only 3.0.
https://github.com/winstonjs/winston-syslog/blob/master/lib/winston-syslog.js#L14
npm install winston-syslog
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 3.2.0-95-generic
gyp ERR! command "/usr/bin/iojs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/bookya_api/node_modules/winston-syslog/node_modules/unix-dgram
gyp ERR! node -v v3.1.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok
npm ERR! Linux 3.2.0-95-generic
npm ERR! argv "/usr/bin/iojs" "/usr/bin/npm" "install" "winston-syslog"
npm ERR! node v3.1.0
npm ERR! npm v2.13.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the unix-dgram package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls unix-dgram
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /usr/local/bookya_api/npm-debug.log
Currently winston-syslog uses a not compatible unix-dgram (0.2.1) module, which makes winston not work on Node 4 and 5.
Per the Breaking Changes list for Winston 3.0, the
winston.setLevels(winston.config.syslog.levels);
line from the setup instructions will no longer work. Is there a workaround for this?
could I use winston-syslog send logs to rsyslog ,thank you!
I get the following error trying to use 2.0.0 with the README.md instructions. Either the instructions need to be updated or there is a syntax error in the new release:
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/share/deathstar/node/modules/logger.js:4:16)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
Error is happening as a result of the require:
1 'use strict';
2
3 const winston = require('winston');
4 require('winston-syslog').Syslog;
5
When hooked into winston as follows:
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Syslog)({host:"localhost",port:514,protocol:"udp4"})
]
});
Then only the first log item is logged. Thereafter, the "this.connect()" function always has an error, it seems like its trying to reconnect to an existing connection. For a potentially bad workaround, I currently have
"return self.queue.push(syslogMsg)" commented out, and all my logs end up in syslog via UDP. UDP does have a fire-and-forget type strategy anyway.
as the title says, this is missing in the npm-registry-version. could you just publish the current github master?
I'm getting an obscure "send 111" error when trying to log using the unix
protocol. Any ideas? The node-syslog
package works fine, as does using logger
at the command line.
var winston = require('winston');
require('winston-syslog').Syslog;
winston.add(winston.transports.Syslog, {protocol:'unix',path:'/dev/log'});
winston.debug('hi')
debug: hi
Error: send 111
at errnoException (/home/gwarner/winston-syslog/node_modules/unix-dgram/src/unix_dgram.js:25:11)
at Socket.send (/home/gwarner/winston-syslog/node_modules/unix-dgram/src/unix_dgram.js:75:24)
at /home/gwarner/winston-syslog/lib/winston-syslog.js:158:21
at [object Object].Syslog.connect (/home/gwarner/winston-syslog/lib/winston-syslog.js:200:9)
at [object Object].Syslog.log (/home/gwarner/winston-syslog/lib/winston-syslog.js:131:8)
at [object Object].Logger.log (/home/gwarner/winston-syslog/node_modules/winston/lib/winston/logger.js:182:17)
at Object.winston.(anonymous function) [as log] (/home/gwarner/winston-syslog/node_modules/winston/lib/winston.js:82:34)
at Object.target.(anonymous function) [as debug] (/home/gwarner/winston-syslog/node_modules/winston/lib/winston/common.js:44:21)
at repl:1:13
at REPLServer.replDefaults.eval (/usr/lib/node_modules/coffee-script/lib/coffee-script/repl.js:33:42)
at repl.js:239:12
at Interface.<anonymous> (/usr/lib/node_modules/coffee-script/lib/coffee-script/repl.js:64:9)
at Interface.emit (events.js:117:20)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.emit (events.js:117:20)
at emitKey (readline.js:1095:12)
at ReadStream.onData (readline.js:840:14)
at ReadStream.emit (events.js:95:17)
at ReadStream.<anonymous> (_stream_readable.js:748:14)
at ReadStream.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:410:10)
at emitReadable (_stream_readable.js:406:5)
at readableAddChunk (_stream_readable.js:168:9)
at ReadStream.Readable.push (_stream_readable.js:130:10)
at TTY.onread (net.js:528:21)
Why are you putting meta
into message
and JSON.stringify
ing it?
https://github.com/indexzero/winston-syslog/blob/master/lib/winston-syslog.js#L125
@indexzero could you please publish them? Thanks in advance!
This broke as part of the 1.2.4 release. "tcp4" is no longer a valid protocol option.
According to the documentation (https://github.com/indexzero/winston-syslog#syslog-configuration), I have to configure my syslog daemon to accept TCP connections in order to use winston-syslog.
However, when logging to syslog in C programs, I can use the openlog
and syslog
functions without any such setup.
I would very much like it if it were possible to use winston-syslog without the configuration step. I am willing and able to put in work to do this, but I don't know quite where to start. I guess I could make a binding to the native openlog
and syslog
functions, but that seems like a ridiculous way to go.
Any further guidance would be greatly appreciated :)
Hi there, I found your extension useful for my project. One thing I am missing is an ability to provide custom formatter for Syslog message format. What I need is a consistent format with python implementation from here.
Exmple:
<prival>appName: message
It would be great to have an ability to specify custom Syslog formatting function through the options. What do you think?
When winston-syslog
attempts to write to a unix socket, if buffer is full, the socket operation will block. When the socket is in non-blocking mode, this results in the socket write operation throwing a EAGAIN
error:
Error: send -11
at errnoException (node_modules/unix-dgram/lib/unix_dgram.js:18:11)
at Socket.send (node_modules/unix-dgram/lib/unix_dgram.js:93:24)
at node_modules/winston-syslog/lib/winston-syslog.js:191:21
at Syslog.connect (node_modules/winston-syslog/lib/winston-syslog.js:253:9)
at Syslog.log (node_modules/winston-syslog/lib/winston-syslog.js:157:8)
at transportLog (node_modules/winston/lib/winston/logger.js:228:15)
at node_modules/async/lib/async.js:157:13
at _each (node_modules/async/lib/async.js:57:9)
at Object.async.each (node_modules/async/lib/async.js:156:9)
at Logger.log (node_modules/winston/lib/winston/logger.js:240:9)
The culprit is line winston-syslog.js:191
:
//
// Write to the `tcp*`, `udp*`, or `unix` socket.
//
if (self.isDgram) {
buffer = new Buffer(syslogMsg);
if (self.protocolType === 'udp') {
self.inFlight++;
self.socket.send(buffer, 0, buffer.length, self.port, self.host, onError);
}
else if (self.protocol === 'unix') {
self.socket.send(buffer, 0, buffer.length, self.path, onError);
}
That line should probably be wrapped in a try/catch block:
When the message does not fit into the send buffer of the socket, send normally blocks, unless the socket has been placed in non-blocking I/O mode. In non-blocking mode it would return EAGAIN in this case. The select(2) call may be used to determine when it is possible to send more data.
I'd love to use the fix introduced by #40 but the current NPM version is far behind what is in master. Could we get a new release on NPM?
Any way to close the socket connection?
Its possible to open a new connection and closing it every message is delivered?
Hi,
I'm using winston with console and syslog transports. While errors on console are shown with stack traces like:
error: Error: dummy error
at expressApp.use (/Users/someuser/Psomeporject/server/server.js:78:12)
at Layer.handle [as handle_request] (/Users/someuser/Psomeporject/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/someuser/Psomeporject/node_modules/express/lib/router/index.js:317:13)
at /Users/someuser/Psomeporject/node_modules/express/lib/router/index.js:284:7
...
Our syslog server is configured to store error leveled messages in an error file, the problem is with the previous error only the first line is stored in the error file, while the rest of the info is written in an accesslog file.
Any help will be appreciated. Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.