Skip to content
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

Fix logfile path #42

Open
jorgerobles opened this issue Jul 6, 2017 · 28 comments
Open

Fix logfile path #42

jorgerobles opened this issue Jul 6, 2017 · 28 comments

Comments

@jorgerobles
Copy link
Contributor

jorgerobles commented Jul 6, 2017

As LaserWeb/LaserWeb4#369 @gerwinbrunner

@cprezzi I've tested patch on electron_bundler
At https://github.com/LaserWeb/lw.comm-server/blob/electron_bundler/server.js#L2843

logFile = fs.createWriteStream(path.join(electronApp.getPath('userData'),"logfile.log"));

I've no commited this, as don't know if thas to be other considerations about branches master & electron

@cprezzi
Copy link
Member

cprezzi commented Jul 6, 2017

Yes, that's the problem! If we fix that only in the electron_bundler branch, it will probably be overwritten by a merge with master, but we can't do electron specific stuff in master.

I think this is a bug in electron for iOS, as a filename without path should use relative path which is the installation directory.

@cprezzi
Copy link
Member

cprezzi commented Jul 6, 2017

Is there something like electron compile switches we could use?

@jorgerobles
Copy link
Contributor Author

I've not found anything on electron-builder

What I would do:

  1. Move all the electron related code to other file (app.js ?)
  2. Encapsulate server code on an class (object/prototype/singleton, or even nested function) and inject dependencies on construct (like a setLogger function that swallows a modified logFile function)
  3. Create a new bootstrap.js file, make it main at package.json.
  4. Bootstrap.js reads an .env file git-ignored in the repo, if not exists instances the server.js class and runs. If exists, load the alternative file on env (like app.js), that runs the server.js instance and the electron part.

@tbfleming
Copy link
Member

Maybe if(electronApp)?

@cprezzi
Copy link
Member

cprezzi commented Jul 6, 2017

@jorgerobles Isn't that a bit overcomplicated? There must be a simpler solution.

@cprezzi
Copy link
Member

cprezzi commented Jul 6, 2017

Ok, found something to get if app is running inside electron:
if (process.versions.electron) {...

@jorgerobles
Copy link
Contributor Author

Well is complicated but abstracts enough to update server freely. Proces.. is of course valid

@cheton
Copy link

cheton commented Jul 6, 2017

You can also use is-electron to detect if current process is running in Electron.

@cprezzi
Copy link
Member

cprezzi commented Jul 6, 2017

Thank's @cheton! That's even better.

@cprezzi
Copy link
Member

cprezzi commented Jul 6, 2017

@jorgerobles
logFile = fs.createWriteStream(path.join(electronApp.getPath('userData'),"logfile.log")); doesn't seem to work on Win10 electron app. I get now error message, but also no logfile.

@jorgerobles
Copy link
Contributor Author

jorgerobles commented Jul 6, 2017 via email

@cprezzi
Copy link
Member

cprezzi commented Jul 6, 2017

Nope, doesn't seem to. I searched the whole drive.
Looks like we need a way to find out if running on Mac 👎 (hate that stuff!)

@tbfleming
Copy link
Member

If(Mac) warn("update to an OS with sane APIs")

@cprezzi
Copy link
Member

cprezzi commented Jul 6, 2017

Ok, found that getPath('userData') is delivering the correct path with \ as directory separator on Windows. Still searching why fs.createWriteStream is not working...

@cprezzi
Copy link
Member

cprezzi commented Jul 7, 2017

I had to make if OS dependant with os.platform.

Who could compile the Mac Version and test if the logfile is written now? (needs .env file with LOG_LEVEL=3 in installation folder).

@jorgerobles
Copy link
Contributor Author

jorgerobles commented Jul 7, 2017 via email

@jorgerobles
Copy link
Contributor Author

image

But does not write log :|

@jorgerobles
Copy link
Contributor Author

@cprezzi cannot get it work on Sierra. Does not find .env

@cprezzi
Copy link
Member

cprezzi commented Jul 7, 2017

I don't know anything about Mac. On Windows, the .env file just has to sit in the same directory as the exe.

@jorgerobles
Copy link
Contributor Author

Yes. I've tried several ways. Seems version bound. On Mavericks ran ok yesterday.

@cprezzi
Copy link
Member

cprezzi commented Jul 7, 2017

Eventually making a .provile file could help: https://apple.stackexchange.com/questions/106778/how-do-i-set-environment-variables-on-os-x

@jorgerobles
Copy link
Contributor Author

Yes, I did the export LOG_LEVEL=3 too 😢

@cprezzi
Copy link
Member

cprezzi commented Jul 7, 2017

Did I mention - I hate Apple?!

@jorgerobles
Copy link
Contributor Author

jorgerobles commented Jul 7, 2017 via email

@cojarbi
Copy link

cojarbi commented Jul 7, 2017

Osx is a God gift. :)

@tbfleming
Copy link
Member

I once gave a MBP 3 months of my development life. I liked the hardware so was willing to give the OS a fair shot. Things kept getting worse over time as I learned more and more of it. It's both a bad UI (very horrid keyboard support, way too much clicky needed) and a bad POSIX system (ancient BSD version missing critical syscalls needed to avoid deadlock in fork/exec).

@DouglasPearless
Copy link

This is how I got the Logfile.txt working on OSX:

Open a Terminal session (from the Utilities folder under Applications)
cd /Applications/Laserweb.app/Contents
export LOG_LEVEL=3
./Laserweb

And as it runs it creates Logfile.txt in that same directory.

Cheers
Douglas.

@cprezzi
Copy link
Member

cprezzi commented Aug 22, 2017

@DouglasPearless Thank you for the information. That makes sense. Setting the environment variable with export only survives in the same terminal session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants