Skip to content

401-midterm-DaveeRyanBenJon/ohNoLogger

Repository files navigation

SlipUp

An npm package library that logs and saves error events in a PostgreSql database.

Version

Contributors: Ryan Geddes, Davee Sok, Ben Hill, Jonathon Lee.

Version: 1.0.0

Project Overview

Purpose of our application is provide user with an easy method to automatically log, filter, and search through their projects error events. The goal is to provide google functionality for error events. Our architecture is based off of splunk.

Architecture

Handles data pipeline through 3 distinct tiers.

- Forwarder
- Indexer
- Search Head

UML Diagram

Our UML diagram will give you insight on how SlipUp is wired. Click below for a whiteboard visual.

Dependencies and Tools

JavaScript

Node.js

SQL

npm

postgres sql

chalk

npm

chalk



Javascript ➡ Node.js ➡ Sql ➡ Inquirer ➡ PostgreSql ➡ Prisma ➡ Npm ➡ Chalk

Getting started

  1. Install SlipUp library with the following commands.
    Note: must have npm installer.
$npm i codefellows-slipup
  1. Input Postgres username.
Upon installation, SlipUp will request Postgres username. 
User must have a Postgres account.  
Note: Mac users should use mac login credentials.
  1. Postgres password.
Upon inputting Postgres username SlipUp will request Posgres password. 
This will allow user to save error logs in Postgres.
  1. Choose port.
User is given the option to assign an env port. If no port is chosen SlipUp will assign default 
port 5432.
  1. Name your Postgres db.
User is given the option to assign a Postgres database name. 
If a name is not chosen SlipUp will assign (Splunk) as the database name.
  1. Note on projects that use Postgres and .env files.
SlipUp uses Prisma as an interface with Postgres database. Prisma by default searches for a 
DATABASE_URL variable to connect to any env file it detects.
Note: Must reserve DATABASE_URL variable name in order for SlipUp to work.

Using SlipUp

Require SlipUp library Ex:

const slipUp = require('codefellows-slipup');


function test1(param) {
  try {
    let num = 123;
    return num.toUpperCase();
  } catch (error) {
    slipUp.logError(error, 'userId', param, 'enter custom note or identifier');
  }
}


SlipUp Exports a singleton that has a method called logError(). logError() accepts the following 4 parameters which will be uploaded automatically to a Sql database when it is called.

slipUp.logError(errorObject, userId, parameter, customNote);

Parameters
errorObject:
This parameter is required. This is the error object in your try catch block. It logs an error object to the database and expects a standard error object. Columns will automatically be created for each error objects in the database that contain the following properties:

  • Error name
  • Error message
  • Error stack

userId:
This parameter is required. It takes a string.
Note: This parameter is used to identify the userId for the programmer. This is used to identify a developer's userId to an error event.

parameter:
This parameter is required. It take a parameter variable.
Note: This parameter is used in the function. Purpose is to track which parameter initiated an error

customNote:
This parameter is required. It takes a string.
This gives the ability for a programmer to create custom notes for error events.

After getting started ➡ CLI commands:

These are command options we can use in our cli(command line interface/ terminal).
Entering the command line

cd into node_modules/codefellows-slipup

Note: In order to use a tag command we need to add two dashes -- before selecting each command. The following commands are valid in the command line.

- $node query get
- $node query update
- $node query delete

List of tag commands for get method Shows you a list of errors stored in your database

  --id
  --userid
  --date
  --errortype
  --userparam

An example of a get command in cli

- $node query get --userid=“userid124” --errortype=ReferenceError

List of tag commands for update method Allows users to update a note for an error. Update error based on recordId and new Note.

--id
--usernote

An example of a update command in cli

- $node query update --id=24 --usernote="this is the new updated note"

List of tag commands for delete method Allows users to delete based on record id.

--id

An example of a delete command in cli

- $node query delete --id=24 

About

Npm package that allows user to save errors using Postgres.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •