logger-elasticsearch
v0.1.5
Published
@elastic/elasticsearch wrapper
Downloads
46
Maintainers
Readme
Initialize Logger
import { LoggerElasticSearch as Logger } from 'logger-elasticsearch';
export class LoggerElasticSearch extends Logger {
constructor({ index, env }: { index: string; env: string }) {
const options = {
cloud: { id: '****-elastic:**************=' },
auth: { username: 'elastic', password: process.env.ELASTIC_PASSWORD },
};
super({ index, env, options });
}
}
Example
const logger = new LoggerElasticSearch({ index: 'users', env: env });
logger.info({
type: 'ADMIN',
userId: user.id,
userEmail: user.email,
action: 'LOGIN',
});
logger.warn({
type: 'ADMIN',
userId: user.id,
userEmail: user.email,
action: 'AUTH_FAILED',
});