Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Man of the day ! Re: [mv] [tag op=log....



******    message to minivend-users from Birgitt Funk <birgitt@my-books.com>     ******


On Sun, 28 May 2000, Bill Randle wrote:

> ******    message to minivend-users from "Bill Randle" <billr@exgate.tek.com>     ******
> 
> OK, gang, here's an attempt to document and summarize what's going on
> with the [tag log] tag:
> 

Yaaaahoooouuu !  

Bill, that is the best contribution I have ever seen on this list so far
for making something clear, fixing it and documenting it. Ever !

Man, you are my Memorial Day's man for the next year or so...8-)

And if you think such kind of documentation and explanation is not
suitable for beginners, you make a big mistake. It is ! It is great !

a.) You have an exact line of source code where even a Perl newbie can try
    its luck to take first steps into the source.
b.) You have _exact_ explanation how the tag works.
c.) You have written text in English for the documentation of a tag
    which is clearly and thoroughly formulated.

I love it. 

Sorry folks, but that's what would help me. I don't know about you. 

I am all exicted, because though I have still not set up and connected my
Linux box, I am rereading Mike's docs line by line for the first time, I
think, since one and half years and I have all the time to make big
question marks and stop every other paragraphs to make notes about what 
I have to learn and read as a non programmer with miniscule system admin
skill (Unix).

You CAN make a connection between Perl source code level, MV tag level 
and verbose, narrative style of explanations plus a man-page-style 
references.

And it is NOT TRUE that it can't be done. But I need quite a library
for that and so much time no decent and honest person would ever have
these days...8-).

OK, Bill I hope you stay with us. That's wonderful. Thanks.

Birgitt


> 1. MV-3.x, MV-4.00, MV-4.01 and MV-4.02 all behave the same.
> 2. Starting with MV-4.03, there was a change in the API for
>    [tag op=log].
> 3. The difference is due not to the way the [tag] tag works,
>    but changes in the do_log()/log() subroutine. [Before 4.03
>    it was do_log(), in 4.03 and later it's log().]
> 
> For those that are still using a pre-4.03 version of minivend,
> here's what works:
> 	[tag log filename]data to log[/tag]  # positional
> 	[tag op=log arg=filename]data to log[/tag]  # named
> 	[tag arg=filename op=log]data to log[/tag]  # named, reverse order
> 
> In versions 4.03 and later, this is what will work:
> 	[tag op=log file=filename]data to log[/tag]  # named
> 	[tag file=filename op=log]data to log[/tag]  # named, reverse order
> 
> These will *not* work in 4.03 and later:
> 	[tag op=log arg=filename]data not logged[/tag]  # named with <arg>
> 	[tag arg=filename op=log]data not logged[/tag]  # named with <arg>
> 	[tag log filename]data not logged][/tag]  # positional
> 	[tag log file=filename]data not logged[/tag]  # mixed positional/named
> 
> One of the new tags in 4.03 is [log], so starting in 4.03 you can also do
> this:
> 	[log filename]data to log[/log]  # positional
> 	[log file=filename]data to log[/log]  # named
> 	[log arg=filename]data to log[/log]  # named, using <arg>
> 
> Note: in 4.03 and later, you can use [log arg=file] but you can not use
> [tag op=log arg=file]. This is because the 'arg=' option is automatically
> translated to 'file=' when it used as part of the [log] tag, but not
> when its used as part of the [tag] tag.
> 
> For those of you interested in the internal details, here's the magic
> line of code that changed between 4.02 and 4.03:
> 
>     --- minivend-4.02/lib/Vend/Interpolate.pm       Thu Mar  9 08:32:43 2000
>     +++ minivend-4.03/lib/Vend/Interpolate.pm       Sat Mar 25 02:16:49 2000
>     @@ -1722,6 +1730,6 @@
> 
>             my $status;
> 
>     -       $file = $Vend::Cfg->{LogFile} if ! $file;
>     +       $file = $opt->{file} || $Vend::Cfg->{LogFile};
>             $file = Vend::Util::escape_chars($file);
> 
> What's not shown above is that $file is the first argument passed to the
> do_log/log subroutine. From the diff you can see that in 4.02, the file
> used for logging is the first argument to the do_log() subroutine, if
> it's specified, otherwise it uses the LogFile defined in the catalog
> config file (if any).
> 
> Starting in 4.03, the filename must be explicity passed as the 'file'
> option, and if that's not defined it uses the catalog config file
> entry (if any). This is why you *must* use 'file=filename' when
> using [tag op=log]. This is also why strictly positional parameters
> [tag log filename] will not work.
> 
> The way the [tag] tag works is that it takes its first positional
> argument (or the op= argument) as the command (e.g. log, time, flag).
> The second positional argument (if any), or the arg= argument is
> passed *as the first parameter* to the operational function called
> by the do_tag() subroutine. Any other named parameters are passed
> thru as part of the $opt hash (except interpolate=, which is
> handled earlier in the process).
> 
> With that said, I have a suggested patch for 4.05 to help the transition:
> 
>     --- minivend-4.04/lib/Vend/Interpolate.pm.orig  Sat Apr 15 20:18:43 2000
>     +++ minivend-4.04/lib/Vend/Interpolate.pm       Sun May 28 09:13:45 2000
>     @@ -1746,6 +1746,7 @@
> 
>             my $status;
> 
>     -       $file = $opt->{file} || $Vend::Cfg->{LogFile};
>     +       $file = $opt->{file} || $Vend::Cfg->{LogFile}
>     +               unless defined $file;
>             $file = Vend::Util::escape_chars($file);
> 
> This will allow the pre-4.03 syntax - both named and positional - to
> work, as well as the new syntax. It also would make the behavior
> match the documentation, which says [tag log filename] should work.
> 
> New shops built with 4.03 and later should probably start using the
> [log] tag to avoid confusion altogether.
> 
> Now, for those of you that have read this far, here's a bonus for you.
> Did you know that [tag op=log] or [log] also can take serveral other
> named parameters? I didn't, until I started looking into this. So, as
> another contribution to the never ending documentation project:
> 
> 	The log tag accepts several optional arguments to specify
> 	how the data to be logged should be processed prior to
> 	writing it to the log file. These options are:
> 
> 	  process=nostrip	Normally, the data string is processed
> 				to change CR LF to LF, remove leading
> 				and trailing spaces and make sure it
> 				ends with a newline. By specifying this
> 				option, the data is logged as written.
> 
> 	  type=text|quote|error	Using the type option specifies possible
> 				additional processing to be done on the
> 				data string and where the data should be
> 				logged. The default operation when no
> 				type= option is specified is to split
> 				the data string into records and fields
> 				and pass to the logDebug() utility function.
> 				The default record delimiter is '\n'; the
> 				default field delimiter is '\t'. The
> 				delimiters can be changed with the
> 				delimiter= and record_delim= options.
> 
> 				The type= option can take on the following
> 				values:
> 				text : the data string is directly
> 				written to the specified file.
> 
> 				error : if a filename is specified with
> 				the file= option, the data string is
> 				formated as a standard error message and
> 				written to that file. If a filename is
> 				not specified, the standard logError()
> 				fucntion is called with the data string
> 				as its argument.
> 
> 				quot[e] : the data string is split into
> 				records and fields and written to the
> 				specified filename using the standard
> 				logData utility function. The record
> 				delimter defaults to '\n' but can be
> 				changed with the record_delim= option.
> 
> 	  delimiter=string	sets the delimiter used to split records
> 				into fields. Default is "\t" (a TAB).
> 
> 	  record_delim=string	sets the record delimiter used to split
> 				the data string into one or more records
> 				before splitting into fields. Default is
> 				"\n" (a newline).
> 
> 	This tag also accepts the hide= and interpolate= options. Normally,
> 	the status returned from the function that actually writes the
> 	data to the logfile is returned, unless hide=1 is specified.
> 
> 
> 	-Bill Randle
> 	billr@exgate.tek.com
> 
> On May 28,  9:40am, cfm@maine.com wrote:
> } Subject: Re: [mv] [tag op=log....
> }
> } [ text/plain
> }   Encoded with "quoted-printable" ] :
> ******    message to minivend-users from cfm@maine.com     ******
> }
> } On Sat, May 27, 2000 at 10:26:58PM -0700, Barry Treahy wrote:
> } > ******    message to minivend-users from Barry Treahy <Barry@BSTent.com>
>     ******
> } > I can understand parameters being position if they are not named, but named
> } > parameters should work regardless of the order and there seems to be
> specific
> } > problems with the tag log in both 3.14-5 and 4.04.  I was pulling my hair
> out
> } > attempting to do page and activity logging and ultimately went to a
> usertag.  To
> } > >
> } > > after changing from MV3 to MV4
> } > > [tag file="<filename>" op=log interpolate=1]
> } > > doesn´ work. After answer from Mike to use
> } > > [tag arg="<filename>" op=log interpolate=1]
> } > > instead, it works. After updating from MV4.03 to MV4.04,
> } > > [tag arg="<filename>" op=log interpolate=1]
> } > > doesn´ work. After rewriting the codes to
> } > > [tag file="<filename>" op=log interpolate=1]
> } > > it works. I´ve read the WHATSNEWS! But couldn´t see any hints about
> } > > this. Any comment?
> }
> } One would expect that named parameters would not be
> } positionally dependant; it's my guess that something else
> } is the culprit.  You'd probably not find that in the README
> } because it's not intentional or known.
> }
> } We, OTOH, use many minivend calls directly.  The parameters
> } to db_array functions changed from mv3 to 4.  I'd not
> } expect changes to that internal API to be documented either;
> } it's **internal**.
> }
> } Minivend has a long evolutionary history.  Code that evolves
> } does tend to spaghetti.  Maybe a week or two ago there was
> } a discussion on /. about it.  My guess is that 4 cleaned up a lot
> } of that but it is a never ending battle.  One needs a whole
> } test harness to check that.  We on this list are that test
> } harness.  ;^)
> }
> } cfm
> } --
> }
> } Christopher F. Miller, Publisher                             cfm@maine.com
> } MaineStreet Communications, Inc         208 Portland Road, Gray, ME  04039
> } 1.207.657.5078                                       http://www.maine.com/
> } Database publishing, e-commerce, office/internet integration, Debian linux.
> 
> 
> 
> -
> To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
> email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
> Archive of past messages: http://www.minivend.com/minivend/minivend-list
> 

-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: