New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@grahamcrackers/logger

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@grahamcrackers/logger

A naive logger for client side applications.

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-50%
Maintainers
0
Weekly downloads
 
Created
Source

@grahamcrackers/logger

A naive logger for client side applications.

basic usage

// src/logger.ts

import { createLogger, LogLevel } from "@grahamcrackers/logger";

export const logger = createLogger({
    // defaults to LogLevel.Log or (0)
    logLevel: LogLevel.Info,
});

log levels

LevelEnumDescription
Log0(Default) Logs all levels
Info1Helpful for debugging in non prod environments
Warn2Show console warnings
Error3Show console errors

settings for different .env

I wanted a logger that I could log during development and if I forget to remove a console log because of reasons it won't output critical info if building for production.

I mainly use vite for front end apps these days so this example is using that setup. If you use webpack, you can translate the environment variables to your setup.

.env

your local set up to log everything

VITE_LOG_LEVEL=0
VITE_LOGGING_ENABLED=true

.env.production

set the log level in prod to only show warnings and errors, or set logging to be disabled entirely.

VITE_LOG_LEVEL=3
# or disable everything
VITE_LOGGING_ENABLED=false
// src/logger.ts

import { createLogger, LogLevel } from "@grahamcrackers/logger";

export const logger = createLogger({
    isEnabled: import.meta.env.VITE_LOGGING_ENABLED,
    logLevel: import.meta.env.VITE_LOG_LEVEL,
});

FAQs

Package last updated on 18 Jul 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc