Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@slipmatio/logger
Advanced tools
Changelog
0.2.0 - 2024-04-13
Readme
Easy and lightweight console logging for your JavaScript and TypeScript projects. Control log levels in development vs production, integrate with third-party log tools and debug Vue applications.
success
, critical
and run
methods for more secure and informative loggingPnpm
pnpm add @slipmatio/logger
Yarn
yarn add @slipmatio/logger
Npm
npm install @slipmatio/logger
The easiest way to use this logger is to use the useLogger
or useVueLogger
helpers. The helpers are configured to print only errors in production and print all but debug messages in development mode unless called with debug=true
. You can also set the logger name
attribute. Both arguments are optional:
import { useLogger } from '@slipmatio/logger'
const logger = useLogger()
Then just use logger
wherever you want:
logger.log('Hello World!')
// > Hello world!
logger.run()
// > 🚀 [main.ts]
Vue logger uses a special logger function that pretty prints ref, reactive, and computed objects for you so instead of unreadable garble you can read the logs easily.
import { ref, computed } from 'vue'
import { useVueLogger } from '@slipmatio/logger'
const logger = useVueLogger('vuelogger', true)
const num = ref(1)
const timesTwo = computed(() => num.value * 2)
console.log('proxy objects', num, timesTwo)
// > proxy objects Object { __v_isShallow: false, dep: undefined, __v_isRef: true, _rawValue: 1, _value: 1 } Object { _setter: setter(), dep: undefined, __v_isRef: true, __v_isReadonly: true, _dirty: true, effect: {…}, _cacheable: true }
logger.log('proxy objects', num, timesTwo)
// > [vuelogger] proxy objects (ref): 1 (computed): 2
Tip: use something like unplugin-auto-import with your bundler to automagically import your logger instance wherever you need it.
You can also instantiate and import the logger manually. It works as you'd expect:
import { Logger, LogLevel } from '@slipmatio/logger'
const logger = new Logger({
// Log levels: DEBUG, INFO, WARN, ERROR, CRITICAL, OFF
logLevel: process.env.NODE_ENV !== 'production' ? LogLevel.INFO : LogLevel.ERROR,
name: 'mylogger',
logFn: myLogFn, // see source for implementation
})
This project was originally born around 2016 and has been copy-pasted in various formats from project to project. As it has been helpful in so many projects, I finally decided to clean it up, convert to TypeScript and release as open source. Some parts of the code are a bit ugly, but it works well enough for most production needs. Contributions welcome!
Follow @uninen on Twitter
FAQs
Better console logging with TypScript support
The npm package @slipmatio/logger receives a total of 51 weekly downloads. As such, @slipmatio/logger popularity was classified as not popular.
We found that @slipmatio/logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.