lw.comm-server
lw.comm-server copied to clipboard
Fix logfile path
As https://github.com/LaserWeb/LaserWeb4/issues/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
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.
Is there something like electron compile switches we could use?
I've not found anything on electron-builder
What I would do:
- Move all the electron related code to other file (app.js ?)
- 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 modifiedlogFile
function) - Create a new bootstrap.js file, make it main at package.json.
- Bootstrap.js reads an
.env
file git-ignored in the repo, if not exists instances theserver.js
class and runs. If exists, load the alternative file on env (likeapp.js
), that runs the server.js instance and the electron part.
Maybe if(electronApp)
?
@jorgerobles Isn't that a bit overcomplicated? There must be a simpler solution.
Ok, found something to get if app is running inside electron:
if (process.versions.electron) {...
Well is complicated but abstracts enough to update server freely. Proces.. is of course valid
You can also use is-electron to detect if current process is running in Electron.
Thank's @cheton! That's even better.
@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.
Probably is working but saving somwhere else :)
El 6 jul. 2017 6:29 p. m., "Claudio Prezzi" [email protected] escribió:
@jorgerobles https://github.com/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.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/lw.comm-server/issues/42#issuecomment-313448529, or mute the thread https://github.com/notifications/unsubscribe-auth/ABoIYP-3gt0um35LD0tLdw91MzGd8k96ks5sLQtogaJpZM4OPgoR .
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!)
If(Mac) warn("update to an OS with sane APIs")
Ok, found that getPath('userData') is delivering the correct path with \ as directory separator on Windows. Still searching why fs.createWriteStream is not working...
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).
I'll do
El 7 jul. 2017 12:19, "Claudio Prezzi" [email protected] escribió:
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).
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/lw.comm-server/issues/42#issuecomment-313644491, or mute the thread https://github.com/notifications/unsubscribe-auth/ABoIYL3GcF_ualTSQitMuGgWWEilfPIDks5sLgYigaJpZM4OPgoR .
But does not write log :|
@cprezzi cannot get it work on Sierra. Does not find .env
I don't know anything about Mac. On Windows, the .env file just has to sit in the same directory as the exe.
Yes. I've tried several ways. Seems version bound. On Mavericks ran ok yesterday.
Eventually making a .provile file could help: https://apple.stackexchange.com/questions/106778/how-do-i-set-environment-variables-on-os-x
Yes, I did the export LOG_LEVEL=3
too 😢
Did I mention - I hate Apple?!
Hmm. Osx could contribute, but I see more culprit on electron or dotenv. I don't miss win viruses.
El 7 jul. 2017 6:10 p. m., "Claudio Prezzi" [email protected] escribió:
Did I say - I hate Apple?!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/lw.comm-server/issues/42#issuecomment-313725251, or mute the thread https://github.com/notifications/unsubscribe-auth/ABoIYIJ0ZeqA4ehBLXsHKkHfu2laWlIVks5sLlhmgaJpZM4OPgoR .
Osx is a God gift. :)
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).
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.
@DouglasPearless Thank you for the information. That makes sense. Setting the environment variable with export only survives in the same terminal session.