Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@seek/logger
Advanced tools
Standardized application Logging
This allows us consistently query request and response across all apps.
import createLogger from '@seek/logger';
// Initialize - by default logs to Console Stream
const logger = createLogger({
name: 'my-app',
});
// Import logged object interfaces from a shared module OR
// declare logged object interfaces
interface MessageContext {
activity: string;
err?: Error | { message: string };
req?: {
method: 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
url: string;
};
}
// Specify the interface and benefit from enforced structure and code completion.
logger.trace<MessageContext>({
activity: 'Getting all the things',
req: { method: 'GET', url: 'https://example.com/things' },
});
logger.error<MessageContext>({
activity: 'Getting all the things',
req: { method: 'GET', url: 'https://example.com/things' },
err: {
message: 'Unexpected error getting things',
},
});
If logger is used with an object as first argument, please use req
, res
and err
to log request, response and error respectively.
req
and res
objects are trimmed to contain only essential logging data.
All other objects passed will be logged directly.
For suggestions on enforcing logged object structures for consistency, see below.
The following trimming rules apply to all logging data:
maxObjectDepth
LoggerOption
.All Bearer tokens (regardless of their placement in the log object) will be redacted by the logger itself.
As trimming operations are not cheap please make sure your application logs only meaningful data which does not contain Buffers, deeply nested objects, large arrays or other large entities, because it might lead to significant performance issues of your application.
Library is utilising Pino. If you would like to customise your logging you could do so by providing options acceptable by pino while creating a logger like so:
import createLogger, { pino } from '@seek/logger';
const logger = createLogger(
{
name: 'my-app',
...myCustomPinoOptions,
},
myDestination,
);
const extremeLogger = createLogger({ name: 'my-app' }, pino.extreme());
Note: createLogger mutates the supplied destination in order to redact sensitive data.
Library is utilizing standard pino serializers with custom req
and res
serialializers.
If other serializers with same keys are provided to the library, they will take precedence over predefined ones.
If you would like to enforce the structure of objects being logged, define the interface to log and specify it as the generic type in the logger functions.
Compatibility should be maintained with the existing serializer functions
.
FAQs
Standardized logging
The npm package @seek/logger receives a total of 4,633 weekly downloads. As such, @seek/logger popularity was classified as popular.
We found that @seek/logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.