This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Description Current Implementation
Create an instance with mandatory log configuration: accessKeyId, secretAccessKey, region and logGroupName.
Configure some options: setLevels() and setInterval().
install() with more options: logStreamNameResolver and messageFormatter.
Switch some options on demand after installation: enable(), disable(), mute() and unmute().
It's too stateful and has so complex interface.
Future Plan
import { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs' ;
import { LoggerFactory , Channel } from 'cloudwatch-front-logger' ;
const client = new CloudwatchLogsClient ( {
credentials : {
accessKeyId : ...,
secretAccessKey : ...,
}
region : ...,
} ) ;
const factory = new LoggerFactory ( {
client,
logGroupName : ...,
logStreamNameResolver : ...,
messageFormatter : ...,
interval : ...,
muted : ...,
} ) ;
factory . addChannel ( new Channel ( 'error' ) ) ;
factory . addChannel ( new Channel ( 'warn' , {
// All parameters can be overridden here
client ,
logGroupName : ...,
logStreamNameResolver : ...,
messageFormatter : ...,
interval : ...,
muted : ...,
) ) ;
const logger = factory . createLogger ( ) ;
const channels = logger . channels ( ) ; // Return channel collection
channels . mute ( ) ; // Mute all channels
channels . get ( 'error' ) . mute ( ) ; // Mute all error channels
channels . get ( 'error' ) [ 0 ] . mute ( ) ; // Mute only single error channel
Or you can create using default channels.
const logger = new LoggerFactory ( {
client,
logGroupName : ...,
logStreamNameResolver : ...,
messageFormatter : ...,
interval : ...,
muted : ...,
} ) . setDefaultChannels ( ) ; Reactions are currently unavailable
Current Implementation
accessKeyId,secretAccessKey,regionandlogGroupName.setLevels()andsetInterval().install()with more options:logStreamNameResolverandmessageFormatter.enable(),disable(),mute()andunmute().It's too stateful and has so complex interface.
Future Plan
Or you can create using default channels.