D
Deno

help

Choose level for std logger

Ssergees2/1/2024
I have some loggers configured using the setup function from std/log. This way levels are hard-coded. I would like to be able to pass a --debug option to my script to activate the DEBUG level, otherwise use INFO and above. Is it possible to achieve this using std/log? If not, what are other libs you can recommend instead?
Mmarvinh.2/1/2024
Detect the CLI flag and set the appropriate log level on the Logger instance (or your custom once). Only log levels equal to the one on the Logger instance or higher are logged
Ssergees2/1/2024
There a function getLogger which return logger instance. It only accepts name as a parameter, no way to pass level there. The level doesn’t seem to have a setter, so this code won’t work:
const logger = getLogger('my_logger');
logger.level = 'DEBUG';
const logger = getLogger('my_logger');
logger.level = 'DEBUG';
Ah okay levelName seems to work
Ccknight2/1/2024
Sounds like you've got a working solution. I've written an alternative logging framework which can do this through the use of environment variables or command line options. https://github.com/onjara/optic
LLeokuma2/1/2024
Much better than std's logger IMO
ABAltair 680b2/1/2024
Perhaps a pr to upgrade std before std 1.0 ?
Ccknight2/1/2024
Thanks! That's kind of you, however, my logger isn't really a good fit for std I think. For starters the fluent interface would be out of place there.
ABAltair 680b2/1/2024
Just a thought. Love your work!
Ssergees2/3/2024
Nice! One thing I’m missing in std logger is the trace level
Iiuioiua2/3/2024
Suggestions for features for std/log are more than welcome! If you guys have any, feel free to open a GitHub issue.

Looking for more? Join the community!

Recommended Posts
folks running into this wiered issue on deploythe deployment is continuously failingfolks running into this wiered issue on deploy the deployment is continuously failing was working fiProblem with the npm package and vite/esbuildhttps://github.com/denoland/denokv/issues/64 Is there a solution to this problem? Has anyone been abHow to send an enum value from Rust to DenoHello there 👋 I am quite a beginner to FFI and I am not sure which resources to read to learn moreDependency injection deno deployDoes anyone know a Decency Injection library or container that works on deno deploy?Fetch request from own server```js try { const response = await fetch('.../ping', { Service keep restartingTwo GitHub projects, prod and customer are created using Deno for data syncing. Both projects are hRun `nvm` using Deno.CommandHello, I am trying to run `nvm` from a Deno script using Deno.Command. ```ts new Deno.Command('nvmCreating custom GitHub Action using DenoHey, I am currently trying to develop my first own custom GitHub Action. I have some trouble settinghow to avoid deprecation warnings in compiled binaries```sh $ pkgx --version warning: Use of deprecated "Deno.stderr.rid" API. This API will be removed inDeno compile with "--no-terminal" don't workI'm trying to compile a very simple file named main.ts ```ts await Deno.writeTextFile('test.txt', 'Hdeno task start not runnning in Powershell.This is the link of the tutorial I am following https://github.com/googleanalytics/ga4-tutorials?tabDeployment ID not available after API deploymentHi - i'm calling the /deployments endpoint after creating a new project: ${API}/projects/${project.`Request` body reading functions: possible error types[This](https://docs.deno.com/runtime/manual/runtime/http_server_apis#inspecting-the-incoming-requestHow to call a JS function from Rust?Hi, I'd like to call a JS function from Rust but I can't seem to find an example that does so. I goView code in Subhosting projectHi there - i'm using the API to create a new project and deployment with Subhosting. Just wondering Stop deno deploy instanceHi everyone, I just deployed my first test deno project on deno deploy. Now I'm wondering how to stoHow can I flush a stream to a response?I'm trying to stream a response but it appears that data is only sent after either a newline is writHoping for a clean way to get an array of filenames in directoryTrying to do something like this: ```typescript const files = Deno.readDirSync(Deno.cwd()).map(x => Support for auto-accessorsI'm playing around with Decorators, it seems like with `"experimentalDecorators": false`, there's a Rust sdk register_actity_typeHey, I am using the core_sdk in rust. I registered an activity, which should be able to consume foll