
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@eclipse-emfcloud/model-logger
Advanced tools
This module provides a flexible logging factory that allows both default console logging and custom logging implementations.
The logger outputs messages to the console by default. To use the logger, import the getLogger
function and create a logger instance with an optional name:
import { getLogger } from '@eclipse-emfcloud/model-logger';
export class AddressBook {
// Retrieve the logger
logger = getLogger('AddressBook');
addAddress = (newAddress: Address): boolean => {
const addresses = this.getAddressBook();
if (!addresses.find((address) => compareAddresses(address, newAddress))) {
logger.debug('Adding a new address');
// [AddressBook]: Adding a new address
addresses.push(newAddress);
return true;
} else {
logger.error('Trying to add an existing address');
// [AddressBook]: Trying to add an existing address
}
return false;
};
}
The logger supports five log levels similar to the standard Console interface methods: log
, error
, debug
, warn
and info
.
You can override the default logging behavior to implement custom logging strategies, such as logging to both console and file system.
To customize the logger, override the LOGGER_FACTORY.getLogger
method with your implementation:
// index.ts
import * as fs from 'fs';
import path from 'path';
import { LOGGER_FACTORY } from '@eclipse-emfcloud/model-logger';
const logFilePath = path.resolve(__dirname, 'logs.txt');
// User-specific logger
LOGGER_FACTORY.getLogger = (name?: string) => ({
error: (...messages: unknown[]) => {
console.error(name ? `${name}:` : '', ...messages);
fs.appendFileSync(
logFilePath,
`[error${name ? ` - ${name}:` : ''}]: ${messages.join(' ')}\n`
);
},
warn: (...messages: unknown[]) => {
console.warn(name ? `${name}:` : '', ...messages);
fs.appendFileSync(
logFilePath,
`[warn${name ? ` - ${name}:` : ''}]: ${messages.join(' ')}\n`
);
},
info: (...messages: unknown[]) => {
console.info(name ? `${name}:` : '', ...messages);
fs.appendFileSync(
logFilePath,
`[info${name ? ` - ${name}:` : ''}]: ${messages.join(' ')}\n`
);
},
log: (...messages: unknown[]) => {
console.log(name ? `${name}:` : '', ...messages);
fs.appendFileSync(
logFilePath,
`[log${name ? ` - ${name}:` : ''}]: ${messages.join(' ')}\n`
);
},
debug: (...messages: unknown[]) => {
console.debug(name ? `${name}:` : '', ...messages);
fs.appendFileSync(
logFilePath,
`[debug${name ? ` - ${name}:` : ''}]: ${messages.join(' ')}\n`
);
},
});
After overriding the factory, all subsequent calls to getLogger()
will return your custom implementation while maintaining the named logger functionality.
FAQs
Logger for ModelManager
The npm package @eclipse-emfcloud/model-logger receives a total of 0 weekly downloads. As such, @eclipse-emfcloud/model-logger popularity was classified as not popular.
We found that @eclipse-emfcloud/model-logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 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.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.