jpsider / RestPS

Simple ReST Framework for Powershell
MIT License
114 stars 30 forks source link

logging calling address #33

Closed grumpy-admin99 closed 4 years ago

grumpy-admin99 commented 4 years ago

I would like to see an option to log calls that hit the endpoint - similar to apache or iis - ie [datetime] [fromIP/port] [toIp/port] [Url called] (or similar)

this can be obtained from the $script:request object: RemoteEndpoint & LocalEndpoint & RawUrl properties.

jpsider commented 4 years ago

2 - Related ticket.

I agree, there needs to be quite a bit of logging added.

grumpy-admin99 commented 4 years ago

current format I have added - in the same folder the routes,json file is in:

[]: []: eg: 2019-12-04T07:07:05 [::1]:56166 [::1]:8080 [GET] /monitor/endpoint/routes
jpsider commented 4 years ago

2 #36 - all related

jpsider commented 4 years ago

Added PowerLumber - for Logging This is the new console output: image

This is the log file output New file created.2020-03-23 18:09:42 INFO: Invoke-StartListener: Starting: http:// Listener on Port: 8081 2020-03-23 18:10:19 INFO: Start-RestPSListener: New Request - Method: GET URL: /endpoint/routes 2020-03-23 18:10:19 INFO: Start-RestPSListener: Processing RequestType: GET URL: /endpoint/routes Args: 2020-03-23 18:10:19 INFO: Invoke-RequestRouter: Importing RouteSet 2020-03-23 18:10:19 INFO: Invoke-RequestRouter: Executing Endpoint Script. 2020-03-23 18:10:19 INFO: Invoke-RequestRouter: Valid Response (200). 2020-03-23 18:10:19 INFO: Start-RestPSListener: Finished request. 2020-03-23 18:11:09 INFO: Start-RestPSListener: New Request - Method: GET URL: /endpoint/shutdown 2020-03-23 18:11:09 INFO: Invoke-StopListener: Stopping HTTP Listener on port: 8081 ...

jpsider commented 4 years ago

ewww it word wrapped!

jpsider commented 4 years ago

So those are the defaults for the new log options -Logfile ($env:SystemDrive/RestPS/RestPS.log) -LogLevel (INFO)

Probably need to tune the messages quite a bit, but it's a start!