Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file pa_lwt_log.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124(* OCaml promise library
* http://www.ocsigen.org/lwt
* Copyright (C) 2009 Jérémie Dimino
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, with linking exceptions;
* either version 2.1 of the License, or (at your option) any later
* version. See COPYING file for details.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*)openCamlp4.PreCastletlevels=["Fatal";"Error";"Warning";"Notice";"Info";"Debug";]letrecapplye=function|[]->e|x::l->let_loc=Ast.loc_of_exprxinapply<:expr<$e$$x$>>lletsplite=letrecauxsectionacc=function|<:expr@_loc<Lwt_log.$lid:func$>>->letlen=String.lengthfuncinletfmt=len>=2&&func.[len-2]='_'&&func.[len-1]='f'andign=len>=4&&func.[0]='i'&&func.[1]='g'&&func.[2]='n'&&func.[3]='_'inletlevel=matchfmt,ignwith|false,false->func|true,false->String.subfunc0(len-2)|false,true->String.subfunc4(len-4)|true,true->String.subfunc4(len-6)inletlevel=String.capitalizeleveliniflevel="Debug"&&(not!Pa_lwt_options.debug)then`DeleteignelseifList.memlevellevelsthen`Log(ign,func,section,level,acc)else`Not_a_log|<:expr@_loc<$a$$b$>>->beginmatchbwith|<:expr<~section>>->aux`Label(b::acc)a|<:expr@_loc<~section:$section$>>->aux(`Exprsection)(<:expr<~section:__pa_log_section>>::acc)a|b->auxsection(b::acc)aend|_->`Not_a_loginaux`None[]eletmake_loc_loc=<:expr<($str:Loc.file_name_loc$,$int:string_of_int(Loc.start_line_loc)$,$int:string_of_int(Loc.start_off_loc-Loc.start_bol_loc)$)>>letmap=objectinheritAst.mapassupermethod!expre=let_loc=Ast.loc_of_expreinmatchsplitewith|`Deletefalse-><:expr<Lwt.return()>>|`Deletetrue-><:expr<()>>|`Log(ign,func,`None,level,args)->letargs=List.mapsuper#exprargsin<:expr<ifLwt_log.$uid:level$>=Lwt_log.Section.levelLwt_log.Section.mainthen$apply<:expr<Lwt_log.$lid:func$~location:$make_loc_loc$>>args$else$ifignthen<:expr<()>>else<:expr<Lwt.return()>>$>>|`Log(ign,func,`Label,level,args)->letargs=List.mapsuper#exprargsin<:expr<ifLwt_log.$uid:level$>=Lwt_log.Section.levelsectionthen$apply<:expr<Lwt_log.$lid:func$~location:$make_loc_loc$>>args$else$ifignthen<:expr<()>>else<:expr<Lwt.return()>>$>>|`Log(ign,func,`Exprsection,level,args)->letargs=List.mapsuper#exprargsin<:expr<let__pa_log_section=$section$inifLwt_log.$uid:level$>=Lwt_log.Section.level__pa_log_sectionthen$apply<:expr<Lwt_log.$lid:func$~location:$make_loc_loc$>>args$else$ifignthen<:expr<()>>else<:expr<Lwt.return()>>$>>|`Not_a_log->super#expreendlet()=AstFilters.register_str_item_filtermap#str_item;AstFilters.register_topphrase_filtermap#str_item;