Comments (8)
Hi @64J0 and thanks for the issue. I'm not sure what's your exact use case, so let me explain how it is meant to work:
- In F# interactive, console logging (via logfn) are enabled per default.
- It's then possible to deactivate logging globally, using
Fsi.disableDebugLogs()
- In a non-F# interactive environment, there should be no logging at all.
Can you explain your use case, and if there's still an issue after all?
Thank you.
from fshttp.
Note:
Lines 3 to 15 in 74b10e3
Lines 45 to 53 in 74b10e3
from fshttp.
I'll close this issue now, thanks again @RonaldSchlenker!
from fshttp.
Nice that you contribute to Giraffe! I have seen the fsx, and wanted to ask you what do you think of some changes:
#r "nuget: FsHttp, 11.0.0"
open System
open FsHttp
// Uncomment if you don't want FsHttp debug logs
// Fsi.disableDebugLogs()
type QueryParams = (string * obj) list
type Url = Url of string
type Title = Title of string
let urls =
{|
notCached = Url "http://localhost:5000/cached/not"
publicCached = Url "http://localhost:5000/cached/public"
privateCached = Url "http://localhost:5000/cached/private"
publicCachedNoVaryByQueryKeys = Url "http://localhost:5000/cached/vary/not"
cachedVaryByQueryKeys = Url "http://localhost:5000/cached/vary/yes"
|}
let queryParams1: QueryParams = [ ("query1", "a"); ("query2", "b") ]
let queryParams2: QueryParams = [ ("query1", "c"); ("query2", "d") ]
let waitForOneSecond () =
do Threading.Thread.Sleep (TimeSpan.FromSeconds 1.0)
let makeRequest (Url url: Url) (queryParams: list<string * obj>) =
let response =
http {
GET url
CacheControl "max-age=3600"
query queryParams
}
|> Request.send
|> Response.toFormattedText
printfn "%s" response
printfn ""
let printRunTitle (Title title) =
printfn "-----------------------------------"
printfn "%s" title
printfn ""
let printTimeTaken (duration: TimeSpan) =
printfn "The time it took to finish:"
printfn "%.2f seconds" duration.TotalSeconds
printfn ""
let run (qps: QueryParams list) title url =
printRunTitle title
let stopWatch = Diagnostics.Stopwatch.StartNew()
for queryParams in qps do
makeRequest url queryParams |> waitForOneSecond
stopWatch.Stop()
printTimeTaken stopWatch.Elapsed
let runFiveRequests = run [ for _ in 1..5 do [] ]
let testPublicCachedNoVaryByQueryKeys () =
let allQueryParams =
[
queryParams1
queryParams1
queryParams2
queryParams2
]
let title = Title "Testing the /cached/vary/not endpoint"
let url = urls.publicCachedNoVaryByQueryKeys
run allQueryParams title url
let testCachedVaryByQueryKeys () =
let title = Title "Testing the /cached/vary/yes endpoint"
let url = urls.cachedVaryByQueryKeys
let allQueryParams =
[
queryParams1
queryParams1
queryParams2
queryParams2
]
run allQueryParams title url
let main () =
runFiveRequests (Title "Testing the /cached/not endpoint") urls.notCached
runFiveRequests (Title "Testing the /cached/public endpoint") urls.publicCached
runFiveRequests (Title "Testing the /cached/private endpoint") urls.privateCached
testPublicCachedNoVaryByQueryKeys ()
testCachedVaryByQueryKeys ()
main ()
The changes are basically:
- use of an anonymous record to access the well-known URLs in a type safe way
- removed redundancies
- used single case DU to for url and title to not accidently mix them on call site + better documentation
- used semantic data types like TimeSpan + better documentation
You can think about it and if you like, use it. Say hi to Jimmy, and have a good day / night.
P.S.: As an alternative to blocking the thread using Thread.Sleep
, you could lift your computation to Async<_>
and use Async.Sleep
(or also Task<_>
).
from fshttp.
Nice, I was not aware of this configuration! Thanks for the information @RonaldSchlenker.
To give more context, I'm using an FSI script to trigger some requests,:
dotnet fsi samples/ResponseCachingApp/test-run.fsx
After adding the Fsi.disableDebugLogs()
to the top of my script, the debug logs are not showing anymore.
from fshttp.
Nice, glad we could solve it :) Have a nice day!
from fshttp.
I'm using it on this PR -> giraffe-fsharp/Giraffe#553
from fshttp.
Great suggestions @RonaldSchlenker, I'm going to apply it there.
from fshttp.
Related Issues (20)
- Remove: printfn "Download response received - starting download..." HOT 2
- Encoding issue in FSI response content printing
- Not escaped query value part HOT 2
- Turning off debug logs in FSI HOT 3
- Update Readme
- Support Repeating Query Parameters
- Async config_transformHttpRequestMessage HOT 6
- ContentTypeForPart custom operations should come after part definition
- Remove ./docs generated output and deploy directy to GH pages via workflow
- Update FS Docs to modernized theme
- Rework build.fsx
- Use implicit yields instead of CustOps
- FsHttp Has an Implicit Dependency on Fsharp.Core 8.0+ from version 12.0.0 on HOT 3
- config_baseUrl shortcut
- FSharp.Core dependency confusion HOT 4
- JSON Docu
- Guard semantic versioning for major changes using binary compat checks in .fsproj HOT 5
- How to strip secrets from requests and responses? HOT 3
- Secrets and Logging / Stringifying
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fshttp.