[Mod] Chat log [chatlog]

JBR
Member
 
Posts: 76
Joined: Sun May 26, 2013 22:04

[Mod] Chat log [chatlog]

by JBR » Sun Jun 09, 2013 11:58

The name says it all. Creates a chatlog.txt file in the world directory.

I don't know if this already exists but I couldn't find one so I decided to make one.

Also there is a monthfirst variable inside the init.lua which does what it says(if true the date for Feb 1st would be 2/1/13 if false it would be(1/2/13) and by default I made it true because i'm guessing most people here are American?

The chat log looks something like this(note: the monthfirst is set to false in this picture):
Image

License: CC0
Download:
4Shared(zip)
Dropbox(zip direct download)

Enjoy!
Last edited by JBR on Sun Jun 09, 2013 18:15, edited 1 time in total.
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Sun Jun 09, 2013 14:20

most people here are european. if i'm not wrong. funny pic, lol
 

Nore
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Sun Jun 09, 2013 14:27

Looks good! However, you have to specify a license (for example, CC0), because public domain is not one.
 

JBR
Member
 
Posts: 76
Joined: Sun May 26, 2013 22:04

by JBR » Sun Jun 09, 2013 16:01

Nore wrote:Looks good! However, you have to specify a license (for example, CC0), because public domain is not one.


Well I don't like the minetest's version of public domain because it has swearing in it and I think public domain is perfectly valid.
 

JBR
Member
 
Posts: 76
Joined: Sun May 26, 2013 22:04

by JBR » Sun Jun 09, 2013 16:02

Mito551 wrote:most people here are european. if i'm not wrong. funny pic, lol


So do you think I should change the default value to false? And the pic is meant to show how you can use it to see whether people are lying or whatever but yeah it is pretty funny.
Last edited by JBR on Sun Jun 09, 2013 16:04, edited 1 time in total.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sun Jun 09, 2013 16:05

JBR wrote:
Nore wrote:Looks good! However, you have to specify a license (for example, CC0), because public domain is not one.


Well I don't like the minetest's version of public domain because it has swearing in it and I think public domain is perfectly valid.

First of all, WTFPL is not "minetest's version of public domain", its a valid and wiedly used license.
Second: public domain is not a license in some countries, thus its not accepted in this forum.
Third: Choose CC0 if you dont like the "swearing" in WTFPL.
 

JBR
Member
 
Posts: 76
Joined: Sun May 26, 2013 22:04

by JBR » Sun Jun 09, 2013 16:11

PilzAdam wrote:
JBR wrote:
Nore wrote:Looks good! However, you have to specify a license (for example, CC0), because public domain is not one.


Well I don't like the minetest's version of public domain because it has swearing in it and I think public domain is perfectly valid.

First of all, WTFPL is not "minetest's version of public domain", its a valid and wiedly used license.
Second: public domain is not a license in some countries, thus its not accepted in this forum.
Third: Choose CC0 if you dont like the "swearing" in WTFPL.


Ok, though what does CC0 stand for?

Edit: Sorry if I came across a bit uptight when I said " public domain is perfectly valid" I didn't mean to be and TBH I don't care much about the license for this.
Last edited by JBR on Sun Jun 09, 2013 16:14, edited 1 time in total.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sun Jun 09, 2013 16:13

JBR wrote:
PilzAdam wrote:
JBR wrote:
Well I don't like the minetest's version of public domain because it has swearing in it and I think public domain is perfectly valid.

First of all, WTFPL is not "minetest's version of public domain", its a valid and wiedly used license.
Second: public domain is not a license in some countries, thus its not accepted in this forum.
Third: Choose CC0 if you dont like the "swearing" in WTFPL.


Ok, though what does CC0 stand for?

http://creativecommons.org/publicdomain/zero/1.0/ 0.5 seconds search in the internet.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Sun Jun 09, 2013 16:13

Is chat not logged in debug.txt?
 

JBR
Member
 
Posts: 76
Joined: Sun May 26, 2013 22:04

by JBR » Sun Jun 09, 2013 16:14

rubenwardy wrote:Is chat not logged in debug.txt?

It's not on mine
 

JBR
Member
 
Posts: 76
Joined: Sun May 26, 2013 22:04

by JBR » Sun Jun 09, 2013 16:15

Hybrid Dog wrote:You could use
0130608124237 Noob message
instead of
(09/06/13 12:42:37) [Noob]: message
to make it more simple.



That seems harder to read to me.
 

JBR
Member
 
Posts: 76
Joined: Sun May 26, 2013 22:04

by JBR » Sun Jun 09, 2013 16:16

PilzAdam wrote:
JBR wrote:
PilzAdam wrote:First of all, WTFPL is not "minetest's version of public domain", its a valid and wiedly used license.
Second: public domain is not a license in some countries, thus its not accepted in this forum.
Third: Choose CC0 if you dont like the "swearing" in WTFPL.


Ok, though what does CC0 stand for?

http://creativecommons.org/publicdomain/zero/1.0/ 0.5 seconds search in the internet.


Yeah your right sorry for being so lazy. Changing now.
 

JBR
Member
 
Posts: 76
Joined: Sun May 26, 2013 22:04

by JBR » Sun Jun 09, 2013 18:15

added dropbox direct download
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Mon Jun 10, 2013 09:26

JBR wrote:
rubenwardy wrote:Is chat not logged in debug.txt?

It's not on mine


You have to do

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
debug_level = 2


or similar setting in settings.conf
 

User avatar
CraigyDavi
Member
 
Posts: 565
Joined: Sat Aug 10, 2013 13:08
GitHub: davisonio
IRC: davisonio or CraigyDavi
In-game: davisonio or CraigyDavi

Re:

by CraigyDavi » Tue Dec 23, 2014 13:43

A crash occurs when someone uses the percentage sign (%) in the chat.
For anyone wanting to use this mod, you could use this code instead to fix it:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local chatlog = minetest.get_worldpath().."/chatlog.txt"

function playerspeak(name,msg)
   f = io.open(chatlog, "a")
   f:write(os.date("(%m/%d/%y %X) [")..name.."]: "..msg.."\n")
   f:close()
end

minetest.register_on_chat_message(playerspeak)
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Re:

by Hybrid Dog » Tue Dec 23, 2014 14:12

CraigyDavi wrote:A crash occurs when someone uses the percentage sign (%) in the chat.
For anyone wanting to use this mod, you could use this code instead to fix it:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local chatlog = minetest.get_worldpath().."/chatlog.txt"

function playerspeak(name,msg)
   f = io.open(chatlog, "a")
   f:write(os.date("(%m/%d/%y %X) [")..name.."]: "..msg.."\n")
   f:close()
end

minetest.register_on_chat_message(playerspeak)

thanks
 

User avatar
Linuxdirk
Member
 
Posts: 497
Joined: Wed Sep 17, 2014 11:21
GitHub: dsohler
In-game: Linuxdirk

Re: [Mod] Chat log [chatlog]

by Linuxdirk » Tue Dec 23, 2014 18:03

Can we have %Y-%m-%dT%X (or a minetest.conf option) to be ISO compliant? :)
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: [Mod] Chat log [chatlog]

by Krock » Tue Dec 23, 2014 19:13

How about:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
os.date("%x") -> date
os.date("%x %X") -> date time
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
WebWolf
Member
 
Posts: 15
Joined: Thu Jun 19, 2014 05:00

Re: [Mod] Chat log [chatlog]

by WebWolf » Thu Dec 25, 2014 20:12

Hi all,
Also instead of the line:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local chatlog = minetest.get_worldpath().."/chatlog.txt"

One could use the following two lines:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local chatdate = (os.date("%Y%m%d")) --chatdate will be, for example, 20150127.txt -->> YYYY MM DD (year month day)
local chatlog = minetest.get_worldpath().."/chatlog/"..chatdate..".txt"

This way, the chat will be saved in daily files (several separated smaller files, one file for each day, in an ordinal and easy to find way), instead of a very big file.

Note: The files will be inside a new directory (a subdirectory) named "chatlog", inside the "worlds/nameOfTheMap" directory.
You need to add some code to create the "chatlog" subdirectory for the first time (before starting the server), or you create it manually (otherwise there will be an error).

Well, just an idea, and trying to share it. :)
Regards,
 

User avatar
Linuxdirk
Member
 
Posts: 497
Joined: Wed Sep 17, 2014 11:21
GitHub: dsohler
In-game: Linuxdirk

Re: [Mod] Chat log [chatlog]

by Linuxdirk » Thu Dec 25, 2014 23:12

Since this mod is CC0 and I like the idea of a chat logfile I created my own version of this mod basing on the same idea. I release my version also under CC0.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
-- Helper function for loading optional values
local function getValid(value, default)
    v = minetest.setting_get(value)
    return (v == nil and default or v)
end

-- Default values
local defaultFile = 'chatlog.%Y-%m-%d.log'
local defaultDate = '%X'
local defaultLine = '[%date%] <%name%> %message%\n'

-- Read values from minetest.conf or set default values
chatlogFilename = getValid('chatlog_logfile_name', defaultFile)
chatlogDateString = getValid('chatlog_date_string', defaultDate)
chatlogLineFormat = getValid('chatlog_line_format', defaultLine)

function chatlogWriteLine(name, message)
    local logfileName = os.date(chatlogFilename)
    local line = chatlogLineFormat
    line = line:gsub('%%date%%', os.date(chatlogDateString))
    line = line:gsub('%%name%%', name)
    line = line:gsub('%%message%%', message)
    f = io.open(minetest.get_worldpath()..'/'..logfileName, 'a')
    f:write(line)
    f:close()
end

minetest.register_on_chat_message(chatlogWriteLine)

A default chatlog line is [%date%] <%name%> %message% … where %date%, %name% and %message% get replaced with the actual date, name and message of the chat line being processed. The default file name is chatlog.%Y-%m-%d.log within the world directory.

Since Lua does not have a function to create folders without loading additional modules (which is insecure because the modules in question might not be installed) or system calls (which are not portable between different operating systems) it is not possible to create sub-directories for log files (except you create them manually beforehand).

Changing the default variables is possible in two locations the first location is in init.lua itself in the section “Default values” but that is not desirable (because one should always separate code and configuration). The second and better solution is to define them in your server’s configuration file or the minetest.conf file.

chatlog_logfile_name allows changing the logfile’s file name. You can use the known date variables here (But as described before: no sub-directories except you create them manually). With chatlog_date_string you describe how the date should be represented in the single chatlog entries. And chatlog_line_format defines the actual chatlog lines.

For chatlog_line_format three additional variables are available: %date% gets replaced by the date defined via chatlog_date_string or its default value, %name% gets replaced with the name of the user sending the chat message and %message% gets replaced with the message itself. Other variables are not being replaced.
 

User avatar
QwertyDragon
Member
 
Posts: 11
Joined: Sat Dec 24, 2016 15:37
GitHub: QwertyDragon
IRC: QwertyDragon
In-game: QwertyDragon LittleBigBunny

Re: [Mod] Chat log [chatlog]

by QwertyDragon » Mon Feb 13, 2017 20:57

I am using Linuxdirk's version:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
    -- Helper function for loading optional values
    local function getValid(value, default)
        v = minetest.setting_get(value)
        return (v == nil and default or v)
    end

    -- Default values
    local defaultFile = 'chatlog.%Y-%m-%d.log'
    local defaultDate = '%X'
    local defaultLine = '[%date%] <%name%> %message%\n'

    -- Read values from minetest.conf or set default values
    chatlogFilename = getValid('chatlog_logfile_name', defaultFile)
    chatlogDateString = getValid('chatlog_date_string', defaultDate)
    chatlogLineFormat = getValid('chatlog_line_format', defaultLine)

    function chatlogWriteLine(name, message)
        local logfileName = os.date(chatlogFilename)
        local line = chatlogLineFormat
        line = line:gsub('%%date%%', os.date(chatlogDateString))
        line = line:gsub('%%name%%', name)
        line = line:gsub('%%message%%', message)
        f = io.open(minetest.get_worldpath()..'/'..logfileName, 'a')
        f:write(line)
        f:close()
    end

    minetest.register_on_chat_message(chatlogWriteLine)


Minetest 0.4.15 self compiled run-in-place on Ubuntu 14.04
And had a server crash with this error:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
2017-02-13 02:09:42: ERROR[Main]: ServerError: Lua: Runtime error from mod 'chatlog' in callback on_chat_message(): .../STABLE/minetest/bin/../mods/chatlog/init.lua:24: invalid capture index
2017-02-13 02:09:42: ERROR[Main]: stack traceback:
2017-02-13 02:09:42: ERROR[Main]:    [C]: in function 'gsub'
2017-02-13 02:09:42: ERROR[Main]:    /STABLE/minetest/bin/../mods/chatlog/init.lua:24: in function <.../STABLE/minetest/bin/../mods/chatlog/init.lua:19>
2017-02-13 02:09:42: ERROR[Main]:    .../STABLE/minetest/bin/../builtin/game/register.lua:412: in function <.../STABLE/minetest/bin/../builtin/game/register.lua:392>


I do not understand what the error is really pointing to.
Tried to reproduce by typing "%" and every other character in chat, but crash does not reproduce for me. So it does not seem like it happens by user typing % or anything. I like this mod and would like to keep using it, unless there is a better option.

Anyone have any suggestions?
 

User avatar
Linuxdirk
Member
 
Posts: 497
Joined: Wed Sep 17, 2014 11:21
GitHub: dsohler
In-game: Linuxdirk

Re: [Mod] Chat log [chatlog]

by Linuxdirk » Wed Feb 15, 2017 22:35

Can’t reproduce with the version provided by Arch Linux.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
$ minetest --version
Minetest 0.4.15 (Linux)
Using Irrlicht 1.8.4
Build info: VER=0.4.15 BUILD_TYPE=Release RUN_IN_PLACE=0 USE_GETTEXT=1 USE_SOUND=1 USE_CURL=1 USE_FREETYPE=1 USE_LUAJIT=1 STATIC_SHAREDIR="/usr/share/minetest"

$ lua5.2 -v
Lua 5.2.4  Copyright (C) 1994-2015 Lua.org, PUC-Rio

$ luajit -v
LuaJIT 2.0.4 -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/

$ uname -rms
Linux 4.9.6-1-ARCH x86_64
 


Return to Mod Releases

Who is online

Users browsing this forum: No registered users and 69 guests

cron