pbrucla / reverse_proxy_group2

Group 2's Reverse Proxy Project - Spring 2024
0 stars 1 forks source link

Add basic Logging and Config reading #7

Closed LLeon360 closed 3 months ago

LLeon360 commented 4 months ago

Added a config to designate where logs go and add logging to log some information and timestamps for successful requests as well as errors.

LLeon360 commented 4 months ago

Currently the dev task for deno task dev just uses --allow-write=. I'm not sure what the best way is to put the log directory from config into here or if I should just not use a config.

epsteinmark commented 3 months ago

Currently the dev task for deno task dev just uses --allow-write=. I'm not sure what the best way is to put the log directory from config into here or if I should just not use a config.

It'd probably be smart to use a config, you can use --allow-write=./log/ if you'd like to specify a directory

LLeon360 commented 3 months ago

I have a config file called config.json that looks like:

{
    "logging" : {
        "logDir" : "logs/",
        "infoLog" : "info_log.log",
        "errorLog" : "error_log.log"
    }
}

just not sure what the best way is to get logDir and put it into the allow-write.

epsteinmark commented 3 months ago

I have a config file called config.json that looks like: just not sure what the best way is to get logDir and put it into the allow-write.

JSON does not have a way to fetch values from other JSON files without writing external code (it would be quite the security vulnerability otherwise!). It also can't self reference, so you'll have to manually write --allow-write=./logs/

That being said, deno.json doesn't seem to be upset if you add your own fields that are not their own, so you can just merge your config.json into deno.json (although this is a personal decision of whether to have a change point in multiple files or just one vs separating deno and your normal config)