-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
first baby steps towards native browser support for the JS sdk of testground #25
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,20 @@ function getLogger (params) { | |
|
||
const transports = [ | ||
new winston.transports.Console({ format }), | ||
new winston.transports.File({ filename: 'stdout', format }) | ||
] | ||
|
||
if (params.testOutputsPath) { | ||
if (process.title !== 'browser') { | ||
transports.push(new winston.transports.File({ | ||
format, | ||
filename: path.join(params.testOutputsPath, 'run.out') | ||
filename: 'stdout' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is due to a merge from an older master version. Should I remove this all together? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand, what did you merge? What would you like to remove? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure anymore, going to clean it up. |
||
})) | ||
|
||
if (!params.testOutputsPath) { | ||
transports.push(new winston.transports.File({ | ||
format, | ||
filename: path.join(params.testOutputsPath, 'run.out') | ||
})) | ||
} | ||
} | ||
|
||
return winston.createLogger({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (creating a thread) You listed a lot of @achingbrain shared an interesting option: It might be enough to use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They solve the purpose of being able to run the testground plan without runtime errors, so that collection get assembled in a trial-error approach. I'll look into the browser field, haven't used that before, so if you could give some practical example of how you see that that would be great. Either way I'll give it a look. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok got'cha, you shared it in the other thread already :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want to get rid of the fallback libraries however we might need to either make winston-js browser friendly (e.g. see winstonjs/winston#2196) or from our end (sdk-js) make the logging different for browser vs node. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This winstonjs/winston#287 was opened in 2013 It's very likely this will take us month(s) to get browser support in winston, We can tackle full support for logging as a follow-up issue (related: testground/testground#1355) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not to worry, that’s already an approach I’m taking on my local replace branch. Sorry if i didn’t communicate that yet There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (creating a thread) You listed a lot of @achingbrain shared an interesting option: It might be enough to use the A few examples he shared: // get-env.js
export function getEnv() {
return process.env
}
// get-env.browser.js
export function getEnv {
return window.testground.env
}
// package.json
"exports": { // used by external imports
"./get-env": {
"browser": "get-env.browser.js",
"import": "get-env.js"
}
},
"browser": { // used by internal imports (e.g by esbuild before building code for running unit tests)
"get-env.js": "get-env.browser.js"
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ok nice, so kinda like what you would do with C macro's in C/C++, go file suffixes and cfg-like macro's in Rust. Got-cha. That does look a lot cleaner indeed. Will play with it this week and see how far I get. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok read the spec, seems fine. Going to adapt the PR to this format. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this standard? Else, could we simplify with something likeprocess.env || window.testground.env
?Got it, that's in the PR description.
Could we move the checks like
if proces.title
into a single functionif (isBrowser())
for example?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will drop this in favour of the browser spec.