Logic Machine Forum
Usernames in log - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: General (https://forum.logicmachine.net/forumdisplay.php?fid=2)
+--- Thread: Usernames in log (/showthread.php?tid=659)



Usernames in log - Thomas - 07.03.2017

Hi
Is it possible to see usernames in Object Logs?
Of course only in situations which allows this kind of information like direct change of a value from the visualisation in setup where login is required.

Thank you


RE: Usernames in log - admin - 07.03.2017

It's not possible to log it this way because username is not a part of the telegram.


RE: Usernames in log - buuuudzik - 07.03.2017

(07.03.2017, 12:14)Thomas Wrote: Hi
Is it possible to see usernames in Object Logs?
Of course only in situations which allows this kind of information like direct change of a value from the visualisation in setup where login is required.

Thank you

These are some functions which could help you:

- special GAs only for visualisation and log them,
- custom js script which will send some special info about user which clicked some button;


RE: Usernames in log - Thomas - 08.03.2017

Dear Admin,
The solution Buuuudzik described is too hardcore. As a new wishlist entry: Would it be possible to create a new "User actions" log? It can log timestamp of the event, IP, username, visu object and it's previous and actual state.


RE: Usernames in log - cekca - 20.04.2017

(07.03.2017, 13:26)buuuudzik Wrote:
(07.03.2017, 12:14)Thomas Wrote: Hi
Is it possible to see usernames in Object Logs?
Of course only in situations which allows this kind of information like direct change of a value from the visualisation in setup where login is required.

Thank you

These are some functions which could help you:

- special GAs only for visualisation and log them,
- custom js script which will send some special info about user which clicked some button;

Hi, could you explain the second point..?? how i can check from js the user...???


RE: Usernames in log - buuuudzik - 20.04.2017

You can prepare .lp file with such script:
Code:
<?
now=os.microtime()
last_login = db:getall('SELECT * FROM user_logs ORDER BY created DESC LIMIT 1')
user = last_login[1].login
print(user)
?>  

and you can use it from js.

As in this thread:
http://forum.logicmachine.net/showthread.php?tid=275&pid=3118&highlight=.lp+file#pid3118

Unfortunately there is at least 1 possible problem when 2 users login in the same time(if more than 1 second it should be ok).

Maybe this is not a perfect solution but at this moment can be helpful. You can also improve it.

A minute ago I've found some solution from Erwin and now it is possible to recognize very precisely who is who.

So .lp file should looks like here:
Code:
<?
require('genohm-scada')
require('dbenv')
db = dbenv:new()

ip = ngx.var.remote_addr
user = db:getall("SELECT login FROM user_logs WHERE ip='" .. ip .. "' ORDER BY created DESC LIMIT 1")
print(user[1].login)
?>



RE: Usernames in log - admin - 20.04.2017

You can use request.username in that lp file.


RE: Usernames in log - buuuudzik - 20.04.2017

(20.04.2017, 15:37)admin Wrote: You can use request.username in that lp file.

Yes this is the most elegant solution and only interesting thing is that when nobody is logged in (only get method in webbrowser) it returns "admin".

With this method .lp file should looks like:
Code:
<?
print(request.username)
?>