proposal about $logAppend

Forum closed. All further discussion to be discussed at https://github.com/OpenKore/

Moderator: Moderators

Message
Author
murasame
Noob
Noob
Posts: 5
Joined: 25 Jan 2009, 01:15
Noob?: No

proposal about $logAppend

#1 Post by murasame »

Background:
After unification of main servers, we in official idRO often receive our id split into two or three id using prefix. Example: I have username "helloworld". previously playing at chaos and loki. after unification, my id divided into two, "helloworld", the main id, and "helloworld:3", the branch. Obviously they do this to preserve character slots of each servers.

Problem:
After this unification, I often use my ":3" id than the main one. and the logs are all gone! After some research, I found that openkore has feature "logAppendUsername" on the config which append username on the log. this make my variable be "storage_helloworld:3_0.txt" which of course, denied by windows.

Solution offered:
I change the code a little, and add new key on config.txt. In conjunction to "logAppendUsername", I add "logAppendCustom" and "logAppendString". When the logAppendUsername set to 1, the rest is ignored. But if it set to 0 (or empty), my kore read logAppendCustom. If it set to 1, I read logAppendString to be appended into log files. So if I use config like this:

Code: Select all

logAppendUsername 0
logAppendCustom 1
logAppendString my_custom_append_string
my openkore will create such as storage_my_custom_append_string.txt for storage log.

The code (src\function.pl, line 501):

Code: Select all

-	# $logAppend = ($config{logAppendUsername}) ? "_$config{username}_$config{char}" : '';
+	# Additional code by murasame to encode colon (':') from username part to prevent log failure
+	if ($config{logAppendUsername}) {
+		$logAppend = "_$config{username}_$config{char}";
+	}
+	else {
+		if ($config{logAppendCustom}) {
+			$logAppend = "_$config{logAppendString}";
+		}
+		else {
+			$logAppend = '';
+		}
+	}
+	# End of additional code
That's all. I don't know if this would be any use for other official RO around the world. But it needed for idRO to work-around the colon-username case. If you think this useful, feel free to commit it. If you think the code is inefficient, feel free to modificate them to meet efficiency criteria.

regards,
murasame

Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: proposal about $logAppend

#2 Post by Technology »

Well formatted bug report murasame.
Could you test out the following piece of code? (its a little more compact and needs less config vars)
config wrote:logAppendUsername 0
logAppendString underscore_appended_string

Code: Select all

$logAppend = ($config{logAppendUsername}) ? "_$config{username}_$config{char}" : "_$config{logAppendString}" || '';
Another possible solution would be filtering out all non-allowed characters for filenames.
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!

sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: proposal about $logAppend

#3 Post by sli »

Stupid Spamhaus blocks my school's wifi IP for whatever reason, so had to wait until I got home to post this.

This could also be done, not sure which would be faster.

Code: Select all

$logAppend =~ s/\W/_/;
Replaces all non-word characters with underscores.
cs : ee : realist

murasame
Noob
Noob
Posts: 5
Joined: 25 Jan 2009, 01:15
Noob?: No

Re: proposal about $logAppend

#4 Post by murasame »

Technology wrote:Well formatted bug report murasame.
Could you test out the following piece of code? (its a little more compact and needs less config vars)
config wrote:logAppendUsername 0
logAppendString underscore_appended_string

Code: Select all

$logAppend = ($config{logAppendUsername}) ? "_$config{username}_$config{char}" : "_$config{logAppendString}" || '';
Another possible solution would be filtering out all non-allowed characters for filenames.
Mew. never think of that way before. I've test that single line and it's work fine.

I prefer discard the logAppendCustom flag and use the logAppendUsername as the trigger to chose between username or own appendString (just in case may be someone just want to log all his id into one file rather than per character).

at least it add another feature. But using the non-word filter also be good. Can be used in conjunction with this. So people still can chose username to append without worrying log failure.

so maybe the final code will be like this(line 501):

Code: Select all

-	$logAppend = ($config{logAppendUsername}) ? "_$config{username}_$config{char}" : '';
+	$logAppend = ($config{logAppendUsername}) ? "_$config{username}_$config{char}" : "_$config{logAppendString}" || '';
+	$logAppend =~ s/\W/_/;
and I ask for apologize. In my previous post, I did add my change to this line of code (previously line 502):

Code: Select all

-	if (($config{logAppendUsername}) && index($Settings::storage_log_file, $logAppend) == -1) {
+	if (($config{logAppendUsername} || $config{logAppendString}) && index($Settings::storage_log_file, $logAppend) == -1) {
The code tested and run well.

regards,
murasame

kali
OpenKore Monk
OpenKore Monk
Posts: 457
Joined: 04 Apr 2008, 10:10

Re: proposal about $logAppend

#5 Post by kali »

Hm. Somehow my post suddenly disappeared.

Anyhow, let's have some other people test it out :) If nobody complains in a few days I'll commit this.

Thanks a lot :)
Got your topic trashed by a mod?

Trashing topics is one click, and moving a topic to its proper forum is a lot harder. You expend the least effort in deciding where to post, mods expend the least effort by trashing.

Have a nice day.

Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: proposal about $logAppend

#6 Post by Technology »

Maybe it would be a good idea to have a function that forces safe filename output.
With an option to remove or replace unsupported character to character.
Or maybe something similar to url encoding. (a function to write in 'safe but encoded', and a function that read and decodes back to original if wanted)
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!

kali
OpenKore Monk
OpenKore Monk
Posts: 457
Joined: 04 Apr 2008, 10:10

Re: proposal about $logAppend

#7 Post by kali »

Anyone opposed?
Got your topic trashed by a mod?

Trashing topics is one click, and moving a topic to its proper forum is a lot harder. You expend the least effort in deciding where to post, mods expend the least effort by trashing.

Have a nice day.

h4rry84
Moderators
Moderators
Posts: 234
Joined: 04 Apr 2008, 09:30
Noob?: Yes
Location: My House
Contact:

Re: proposal about $logAppend

#8 Post by h4rry84 »

go ahead

Locked