
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@akkadu/logger
Advanced tools
The point is to have one unified implementation for backend and frontend. To achieve this we load logger configurations either from process.env or localStorage
The point is to have one unified implementation for backend and frontend. To achieve this we load logger configurations either from process.env or localStorage
yarn add @akkadu/logger
This works in client and server-side, pew pew pew!
// ESM
import Logger from '@akkadu/logger
// CJS
const Logger = require('akkadu/logger')
The logger has 6 levels. Each level will log itself AND the levels below it. For instance logLevel 'info' will log info,warn,error and off. Off is implemented as a method for testing purposes
The logLevel affects two things:
You can define the logLevel of the logger itself to be one of the following - insane - debug - info - warn - error - off
// the default way to use the logger is just to initialize it, in this case
// we read the logLevel from process.env, or from the browser environment
const logger = new Logger()
// or we can define the logLevel in the initialization
// each logger is an isolated instance, so we can have different levels of logging
// in different files if needed.
const logger = new Logger({logLevel:'info'})
The client side env reading is a bit special, so an additional word about that. To set the logLevel from the env there are 2 different ways
The logLevels available for logging are
const logger = new Logger()
logger.info('The server is listening on port 3000')
logger.error('User object should be defined')
The default config of the logger is:
const defaultConfig = {
logToConsole: true,
logLevel: 'info',
output: []
}
The options you can pass to logger are
{
testEnv: Boolean // if we are running in test env
logToConsole:Boolean // if we want to log to console
outputs:[ // custom output, we will push logs to there arrays
{logOuput:[], logLevel:string}
]
}
SERVERSIDE - default logLevel should be info
Let's say that we are on the serverside, and we just want to have default logs on production
const logger = new Logger() // by default the log level is info, so anything below info will be logged
logger.info('server is listening on port 3000') // will be logged
logger.debug(['created new user',userObject]) // will not be logged
Now we have problems on the server and we want to also display debug logs. We can either:
// 1. go to .env and set LOGLEVEL='DEBUG' to get all debug logs everywhere
// 2. or change the logger initialiation in the file we are debugging
const logger = new logger({logLevel:'debug'})
logger.debug(['created new user',userObject]) // will log!
CLIENT SIDE - default logLevel should be warn
Let's say that we are in browser environment on staging. We are running a nuxt server, so process.env is available
const logger = new Logger() // the logLevel will be read from process.env - default should be warn
logger.info(['Joined room',roomData]) // should not log
logger.debug(['Sending socket message', message]) // should not log
logger.warn('this route is deprecated') // should log
Now let's say that we have problems with sending messages throught socket connection.
// 1. we can change our logger initialization in the problem file with new logger({logLevel:debug})
// 2. we can write in console localStorage.logLevel = 'debug' and refresh the page
// in both cases
logger.info(['Joined room', roomData]) // should log
logger.debug(['Sending socket message', message]) // should log
logger.warn('this route is deprecated') // should log
<3 BadgrHammer, please share any questions or suggestions to me.
FAQs
The point is to have one unified implementation for backend and frontend. To achieve this we load logger configurations either from process.env or localStorage
The npm package @akkadu/logger receives a total of 0 weekly downloads. As such, @akkadu/logger popularity was classified as not popular.
We found that @akkadu/logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.