Module Logfilter


module Logfilter: sig .. end
Generalist logs filter main module.
Author(s): Gamall Wednesday Ida


Global parameters


type opacity_t =
| OPAQUE (*nothing is copied to stderr. All original input can be lost*)
| RESIDUES (*everything the filter rejected is copied to stderr*)
| TRANSPARENT (*all input data is copied to stderr, regardless of what the filter did with it*)
What kind of information goes through stderr ?
val _opacity : opacity_t Pervasives.ref
opacity setting

Predicate and Transform mechanism
Using a hash table for internal storage
type predicate = string -> bool 
Type for predicates
type transform = string -> string 
Type for transformations
type 'a record = 'a * string * string 
Record of a registered function: function, short description, help page text
val get_fun : 'a * 'b * 'c -> 'a
Get the function back from a record
val get_shortdesc : 'a * 'b * 'c -> 'b
Get the short description from a record
val get_helpt : 'a * 'b * 'c -> 'c
Get the help page text from a record
val hp : (string, predicate record) Hashtbl.t
The predicates hash table
val ht : (string, transform record) Hashtbl.t
The transforms hash table
val register_fun : ('a, 'b) Hashtbl.t -> 'a -> 'b -> unit
Register a function in its table
val regp : predicate -> string -> string -> string -> unit
Register a predicate
val regt : transform -> string -> string -> string -> unit
Register a tranform
val get_record : (string, 'a) Hashtbl.t -> string -> 'a
Get the whole record of a function from its option name
Raises Failure and abort if no record can be found
val get : (string, 'a * 'b * 'c) Hashtbl.t -> string -> 'a
Get a function from its option name
val getp : string -> predicate
Get predicate from option name
val gett : string -> transform
Get transform from option name

Predicates
Predicates determine whether a given line must be kept or discared

Definitions

val p_all : 'a -> bool
Keep all lines
val p_none : 'a -> bool
Keep none
val reg_jkdlg : Str.regexp
Jka logs public dialogue lines pattern
val reg_jkprivdlg : Str.regexp
Jka logs private dialogue lines pattern
val p_jk_dlgs : string -> bool
Keep only public dialogues
val p_jk_adlgs : string -> bool
Keep all dialogues
val p_jk_pdlgs : string -> bool
Keep only private dialogues
val reg_jkevent : Str.regexp
JK logs events lines pattern
val p_jk_event : string -> bool
Keep JK logs events lines
val reg_jkservinit : Str.regexp
JK server initialisation message pattern
val p_jk_servinit : string -> bool
Keep JK server initialisation message
val reg_q3uiip : Str.regexp
Q3 userinfo strings containing IPs pattern
val p_q3uiip : string -> bool
Keep Q3 userinfo strings containing IPs

Registration

val do_register_predicates : unit -> unit
Add all predicates to the record

Transforms
Transforms turn lines which are kept by the predicate into something more legible
val t_id : 'a -> 'a
The identity transform: no alteration of the original. Default transform.
val t_debugmark : string -> string
Debug mark
val reg_q3color : Str.regexp
Q3 colours escape sequence pattern
val remove_q3colors : string -> string
Remove Q3 colour escape sequences
val t_jk_dlgs : string -> string
JKA logs dialogue lines pretty-print, private and public
val t_jk_event : string -> string
JK log events pretty-print
val t_cut80 : string -> string
Cut to 80 chars by the left
val t_rcut80 : string -> string
Cut to 80 chars by the right
val t_q3uiip : bool -> string -> string
Separate IP from q3 userinfo strings

Registration

val do_register_transforms : unit -> unit
Add all tranforms to the record

Entry point

val welcome : string
Welcome message
val disp_welcome : unit -> unit
Display the welcome message
val disp_help : unit -> unit
Help poor dear little user through the command-line options...
val disp_fun : string -> 'a * string * 'b -> unit
Display function and short description
val disp_table : string -> (string, 'a * string * 'b) Hashtbl.t -> unit
Display a whole functions table
val disp_preds : unit -> unit
Display all valid predicates
val disp_trans : unit -> unit
Display all valid transforms
val print_help_page : string -> 'a * string * string -> unit
Print the help page from an optn and a record
val print_help_page_line : string -> 'a * string * string -> unit
The same as print_help_page with extra blank lines
val request_help_page : string -> unit
Display a help page concerning a function, identified by its option name
val disp_doc : unit -> unit
Display the whole documentation of all functions
val _no_blank : bool Pervasives.ref
Must I remove blank lines from the output ? This is a kind of bonus filter...
val do_filter : (string -> bool) ->
(string -> string) -> (string -> bool) -> (string -> string) -> unit
CORE FUNCTION : Waits for input on stdin, and decides whether to send it to stdout and/or stderr, with respect to user selected opacity setting, predicate and transformation
val get_opacity : string -> opacity_t
Get the opacity setting from user command-line string
val _p : string Pervasives.ref
Selected predicate
val _t : string Pervasives.ref
Selected transform
val _rp : string Pervasives.ref
Selected predicate for lines rejected to stderr
val _rt : string Pervasives.ref
Selected transform for lines rejected to stderr
val init : unit -> unit
Register everything...
val pcml : string list -> unit
Parse the command-line
val main : unit -> unit
Entry point