Git Product home page Git Product logo

cloudwatch-front-logger's Introduction

cloudwatch-front-logger's People

Contributors

mpyw avatar princed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cloudwatch-front-logger's Issues

Log all levels

First, thanks to share your work.

Could you have a function for each log level Error, Warn, Info, Debug, Trace mapped on console functions?

Arguments

Can you put args to logs? When I use console.log('test', var) I get only message "test"

Need Refactoring

Current Implementation

  1. Create an instance with mandatory log configuration: accessKeyId, secretAccessKey, region and logGroupName.
  2. Configure some options: setLevels() and setInterval().
  3. install() with more options: logStreamNameResolver and messageFormatter.
  4. 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();

Unable to change stream name

I follow your instructions but I could not change at all the log stream name.

try several approaches but I don't know what I'm doing wrong.

I'm using vuejs and trying to use in app file.

First Approach, using the same code as you suggest

const logger = new Logger(process.env.VUE_APP_CLOUDWATCH_ACCESS_KEY, process.env.VUE_APP_CLOUDWATCH_SECRET_ACCESS_KEY, 'eu-west-2', process.env.VUE_APP_CLOUDWATCH_LOG_GROUP);
logger.install({
                       async logStreamNameResolver() {
                       const fp = await FingerprintJS.load()
                       const { visitorId } = await fp.get()
                       return visitorId
  },
               });

Result
Screenshot 2022-01-05 at 15 54 31

The second Approach was to return a string

const logger = new Logger(process.env.VUE_APP_CLOUDWATCH_ACCESS_KEY, process.env.VUE_APP_CLOUDWATCH_SECRET_ACCESS_KEY, 'eu-west-2', process.env.VUE_APP_CLOUDWATCH_LOG_GROUP);
logger.install({
                   logStreamNameResolver() {
                       return 'test';
                   },
               });

Result
Screenshot 2022-01-05 at 15 54 31

It seems the function is not replaced somehow. Am I missing something?

Issue with cloudwatch-front-logger package in Ionic/angular

i had used cloudwatch-front-logger package for Ionic/angular

It works perfectly and send logs to cloudwatch but sometimes it return custom errors like

message: "Log events in a single PutLogEvents request must be in chronological order."

message: "The given sequenceToken is invalid. The next expected sequenceToken is: 49624933166923263368354481303481754674738400532447100946"

Is there any way to avoid that?

It hits below api

https://logs.eu-west-1.amazonaws.com/

Payload -> 
logEvents: [{,…}]
logGroupName: "Demo"
logStreamName: "front"
sequenceToken: "49628590183593312425478787996364355797"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.