Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
@financial-times/n-logger
Advanced tools
Readme
This package provides a Winston wrapper which sends server-side logs to Splunk's HTTP Event Collector (HEC).
Please note that this package is not only used by the Customer Products team. Please be mindful of this as any changes may impact other teams, such as Internal Products, differently.
This package is compatible with the Node version defined by engines.node
in package.json
(run command nvm use
to switch your local Node version to the one specified in .nvmrc
) and is distributed on npm.
npm install --save @financial-times/n-logger
After installing the package you will need to configure your production application with the SPLUNK_HEC_TOKEN
environment variable. If you are working on a next-
application this will be specified in the shared secrets folder in Vault.
import logger from '@financial-times/n-logger';
logger.log('info', 'Saying hello');
logger.info('Saying hello');
logger.warn('Everything’s mostly cool');
logger.error('Uh-oh', { field: 'some value' });
logger.info({ event: 'UPDATE_NOTIFICATION', data: data });
const error = new Error('Whoops!');
logger.error('Uh-oh', error, { extra_field: 'boo' });
If using CommonJS modules:
const logger = require('@financial-times/n-logger').default;
The default loggers are configured based on the presence of several environment variables. A Console
logger is always registered and a SplunkHEC
logger is registered depending on which variables are set:
MIGRATE_TO_HEROKU_LOG_DRAINS
: Whether the app should rely on Heroku log drains in production. If this variable is set to an unempty string then the app will not log directly to Splunk. Instead it will log JSON strings to the console which should be picked up by Heroku and forwarded on to Splunk. Do not set this environment variable before configuring a Heroku log drain in your application.
SPLUNK_HEC_TOKEN
: The Splunk token to use when manually sending logs to Splunk. If this is set to an unempty string then a SplunkHEC logger will be configured.
SPLUNK_LOG_LEVEL
: The log levels to send to Splunk, used by both Heroku log drains and the SplunkHEC logger. Defaults to warn
.
CONSOLE_LOG_LEVEL
: The log levels to send to the console. Defaults to silly
. This environment variable is ignored in favour of SPLUNK_LOG_LEVEL
when MIGRATE_TO_HEROKU_LOG_DRAINS
is in use.
CONSOLE_LOG_UNCOLORIZED
: Set to true
to disable log coloring. By default console logs are colorized. This environment variable is ignored when MIGRATE_TO_HEROKU_LOG_DRAINS
is in use as JSON logs are not colorized.
If you are making a change to n-logger
it is worth testing it locally to check it is sending logs successfully before merging.
const logger = require('./dist/main').default;
logger.warn('Testing Testing Testing');
logger.warn({ event: 'HELLO_WORLD', message: 'Testing 1 2 3', count: 5 }, {fizz: 'buzz'});
In the terminal export NODE_ENV=production
, export SYSTEM_CODE=next-foo-bar
and export SPLUNK_HEC_TOKEN={token}
(find this token in the next/shared
folder in Vault).
Run node test
in the terminal.
If everything is working correctly, you should be able to see your test logs in Splunk with the query index=heroku source="/var/log/apps/heroku/ft-next-foo-bar.log"
.
level
can be silly, debug, verbose, info, warn or errormessage
is optionalError
objects{event: 'My_EVENT', error}
. This will result in no details of the error being logged**Additional metadata
properties to be appended to every subsequent log call.
The Winston object
FAQs
This package provides a Winston wrapper which sends server-side logs to Splunk's HTTP Event Collector (HEC).
We found that @financial-times/n-logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
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.
Research
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.