ajstacy / adze Goto Github PK
View Code? Open in Web Editor NEWA library for shaping your JavaScript logs.
License: Apache License 2.0
A library for shaping your JavaScript logs.
License: Apache License 2.0
https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
By implementing structuredClone and removing defaultsDeep we can eliminate lodash as a dependency and reduce our package size.
Does adze support pretty printing JSON objects/arrays to the terminal? That could be really useful especially if JSON objects could be color highlighted.
In the Adze Concepts section of the docs, the modifiers subsection has incorrect verbiage on the example. We need to update the example code and snap new screenshots.
Create a website for Adze that includes documentation, examples, and a playground.
Create a couple of convenience log data formatter functions for use within log listeners that accepts the log data object.
formatHumanReadable(data);
formatMachineReadable(data);
Allow Shed to be configured to cache logs to local storage to add persistance across refreshes and reloads.
Rather than letting the user create a new namespace on the fly, it would be useful to control them centrally so that you can know what namespaces exist. This will assist with filtering logs because you can view all app namespaces at a glance.
GCPs logs are rather odd. Using adze normally results in one log per line. So if I log an object, with 5 properties, I see 5 separate logs. I have tried to do a bit of research and it's something to do with stdout.
I tried using machineReadable
, but it resulted in this error:
Converting circular structure to JSON
--> starting at object with constructor 'Socket'
| property 'parser' -> object with constructor 'HTTPParser'
--- property 'socket' closes the circle
Any ideas on how to configure adze to "work"? They have a few packages for compatability with loggers:
When a log chain is started the label() method should return an extended log object that contains the counter, timer, and mdc methods. This will allow TS to throw errors when a user attempts to write a log using a counter, timer, or mdc method that hasn't already specified a label.
This will allow the modifier queue to be removed since labels will be enforced to occur before count, time, and mdc.
Write documentation explaining global environment variables that can be used for toggling logs during unit testing.
Logs should be able to have styling disabled through a flag. In some cases, stdout will print style characters which is undesirable.
Follow the steps here to setup SSL: https://docs.github.com/en/pages/getting-started-with-github-pages/securing-your-github-pages-site-with-https
I've run into a few situations while using adze where I wish I had a way to modify or intercept the log data before it is terminated. Something like this would be exceptionally useful.
adze({
middlware: (logData) => {
if(foo) {
// terminate as is
return logData
} else {
// do not log this request
return null
}
}
});
// Or
adze().intercept((logData) => {/* do something else */}).log("log something")
This would be exceptionally handy for writing custom logging code ontop of adze. In my case this would be helpful for building a react hook where a log call needs to be placed inside of an effect.
const useAdzeEffect = () => {
const [logDataState, setLogDataState] = useState(null);
const logger = adze().intercept((currentLogData) => {
if(logDataState) {
return currentLogData;
} else {
setLogDataState(currentLogData)
}
});
useEffect(() => {
if(logDataState) {
logDataState
logger.log(...logDataState.args)
}
}, [logData])
return logger;
}
const MyComponent = () => {
let logger = useAdzeEffect()
logger.label("MyComponent").log("Some state variable")
//...
}
Another use could be modifying the log level or isSilent keys in place in special cases, such as a function taking too long.
function mySometimesSlowFunction() {
adze().label('slowfn').time.verbose('Begin slow function')
// occasionally slow code...
adze().label('slowfn').timeEnd.intercept(
(logData) => {
if(logData.data.timeElapsed > 10000){
logData.level = 0;
}
return logData
}
).verbose('Function complete')
}
Going back to react, adding the ability to not log every other render when strict mode is enabled would be very handy.
function useStrictLogger() {
const [countState, setCountState] = useState(0)
adze().intercept(
(logData) => {
if(countState % 2 === 0){
return null
}
return logData
}
).log('Rendered component')
setCountState(countState + 1);
}
And some other helpful use cases:
This is only a suggestion of course, and I realize an 'escape hatch' like this is not best practice and much of this can be accomplished by filtering in the shed. That said, from my experience using adze, not having a way to add my own modifiers has been an inconvenience when using an otherwise lovely logging library.
Create a backend Node service that provides an API for collecting logs remotely. It should be built on Docker and also provide some basic reporting.
Currently when applying namespaces to a log via the namespace
or ns
methods you must pass in an array of strings if you want to apply multiple namespaces. This API could be simplified to allow a restof args operator to collect the multiple namespaces.
// Current API
adze().ns(['namespace-1', 'namespace-2']);
// Proposed API
adze().ns('namespace-1', 'namespace-2');
Write readme documentation for Adze.
The config docs for Adze Configuration show's filters
as a config property but doesn't document it in the description table below.
Under the Adze Concepts page there should be a common usage example to clarify the primary way Adze is meant to be used.
Allow the user to specify default meta data on a new Adze instance that is applied to every child log.
Adze should support a URL param for controlling the logging environment. The param name should be configurable by the user.
Batteries-Included:
Write a listener function that write machine readable (JSON) logs to a file.
The bundling concept in the documentation isn't immediately clear how it works. Expound on the documentation for this feature.
Batteries-Included:
Write a function for listening to logs and writing the data to a file in a human readable format.
The library should export a type for an Adze factory function so that if an adze factory is being passed as an argument it can be strongly typed with TypeScript.
Currently filtering can only occur with a configured Shed. Adze logs should support filter configuration and as logs are terminated they will self-filter based on the config.
Unbeknownst to me a standard function already exists for creating deep clones of objects named structuredClone. Current implementations of the lodash cloneDeep function should be removed in favor of this. This will improve performance and reduce bundle size.
https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
The example for the test modifier has incorrect text and comment for the x === y log.
The preview image shows the old "attention" log level that is now replaced by alert. Update the image to reflect the API changes.
The documentation for Level Filter was never updated after copying the documentation block.
Batteries-Included:
Create a listener function that enables the user to configure an API endpoint to send the logs to in JSON format.
The current behavior with the namespace modifier is that multiple calls to it will overwrite the namespaces that are applied to the log rather than adding to them.
adze().ns('foo').ns('bar').log('Testing');
The log generated by this will only have the namespace of "bar." Ideally it would have "foo" + "bar".
Rename Shed to GlobalStore for clarity.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.