[Pkg-ocaml-maint-commits] [approx] 04/16: use syslog interface from ocamlnet

Eric Cooper ecc at cmu.edu
Mon Dec 9 15:44:03 UTC 2013


This is an automated email from the git hooks/post-receive script.

ecc-guest pushed a commit to branch upstream
in repository approx.

commit c37492baff9c66dc956f96e7e63dbf4b0e122f26
Author: Eric Cooper <ecc at cmu.edu>
Date:   Sat Mar 9 14:54:04 2013 -0500

    use syslog interface from ocamlnet
---
 _tags                |  6 +++---
 log.ml               | 37 ++++++++++++++++++++++++++++++-------
 myocamlbuild.ml      |  4 ++--
 tests/_tags          |  8 +++-----
 tests/syslog_test.ml | 14 --------------
 5 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/_tags b/_tags
index 4f5981f..2597af6 100644
--- a/_tags
+++ b/_tags
@@ -1,5 +1,5 @@
 # approx: proxy server for Debian archive files
-# Copyright (C) 2011  Eric C. Cooper <ecc at cmu.edu>
+# Copyright (C) 2013  Eric C. Cooper <ecc at cmu.edu>
 # Released under the GNU General Public License
 
 <**/*.{mli,ml}>: warn_error_A
@@ -7,10 +7,10 @@
 <approx.ml>: use_pcre, use_netstring, use_netcgi, use_nethttpd
 <config_file.ml>: use_pcre
 <import.ml>: use_pcre
-<log.ml>: use_syslog
+<log.ml>: use_netsys
 <url.ml>: use_netstring
 <util.ml>: use_pcre, use_sha
 
 <**/*.{byte,native}>: use_unix, use_pcre, use_sha
-<*.{byte,native}>: use_bigarray, use_syslog, use_netsys_oothr, use_netsys, use_netstring
+<*.{byte,native}>: use_bigarray, use_netsys_oothr, use_netsys, use_netstring
 <approx.{byte,native}>: use_equeue, use_netcgi, use_nethttpd
diff --git a/log.ml b/log.ml
index b041488..3603df9 100644
--- a/log.ml
+++ b/log.ml
@@ -1,9 +1,8 @@
 (* approx: proxy server for Debian archive files
-   Copyright (C) 2011  Eric C. Cooper <ecc at cmu.edu>
+   Copyright (C) 2013  Eric C. Cooper <ecc at cmu.edu>
    Released under the GNU General Public License *)
 
 open Printf
-open Syslog
 
 let stderr_log _ msg =
   prerr_string msg;
@@ -14,13 +13,37 @@ let writer = ref stderr_log
 let log_to_stderr () =
   writer := stderr_log
 
+let facility_of_string s =
+  match String.lowercase s with
+  | "authpriv" -> `Authpriv
+  | "cron" -> `Cron
+  | "daemon" -> `Daemon
+  | "ftp" -> `Ftp
+  | "kern" -> `Kern
+  | "local0" -> `Local0
+  | "local1" -> `Local1
+  | "local2" -> `Local2
+  | "local3" -> `Local3
+  | "local4" -> `Local4
+  | "local5" -> `Local5
+  | "local6" -> `Local6
+  | "local7" -> `Local7
+  | "lpr" -> `Lpr
+  | "mail" -> `Mail
+  | "news" -> `News
+  | "syslog" -> `Syslog
+  | "user" -> `User
+  | "uucp" -> `Uucp
+  | "default" -> `Default
+  | _ -> Util.invalid_string_arg "syslog facility" s
+
 let log_to_syslog () =
   let facility = facility_of_string Config.syslog in
   let ident =
     sprintf "%s[%d]" (Filename.basename Sys.argv.(0)) (Unix.getpid ())
   in
-  let log = openlog ~facility ident in
-  writer := syslog log
+  Netsys_posix.openlog (Some ident) [] facility;
+  writer := Netsys_posix.syslog facility
 
 let message enabled level =
   (* ensure message is newline-terminated,
@@ -32,6 +55,6 @@ let message enabled level =
   in
   ksprintf (fun str -> if enabled then !writer level (terminate str))
 
-let error_message fmt = message true `LOG_ERR fmt
-let info_message fmt = message Config.verbose `LOG_INFO fmt
-let debug_message fmt = message Config.debug `LOG_DEBUG fmt
+let error_message fmt = message true `Err fmt
+let info_message fmt = message Config.verbose `Info fmt
+let debug_message fmt = message Config.debug `Debug fmt
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
index 515980b..f646941 100644
--- a/myocamlbuild.ml
+++ b/myocamlbuild.ml
@@ -1,5 +1,5 @@
 (* approx: proxy server for Debian archive files
-   Copyright (C) 2011  Eric C. Cooper <ecc at cmu.edu>
+   Copyright (C) 2013  Eric C. Cooper <ecc at cmu.edu>
    Released under the GNU General Public License *)
 
 open Ocamlbuild_plugin
@@ -7,7 +7,7 @@ open Command
 open Pathname
 
 let libraries =
-  ["pcre"; "sha"; "syslog";
+  ["pcre"; "sha";
    "netsys_oothr"; "netsys"; "equeue";
    "netstring"; "netcgi2:netcgi"; "nethttpd"]
 
diff --git a/tests/_tags b/tests/_tags
index 7682316..6cac208 100644
--- a/tests/_tags
+++ b/tests/_tags
@@ -1,16 +1,14 @@
 # approx: proxy server for Debian archive files
-# Copyright (C) 2009  Eric C. Cooper <ecc at cmu.edu>
+# Copyright (C) 2013  Eric C. Cooper <ecc at cmu.edu>
 # Released under the GNU General Public License
 
 <sha1_test.ml>: use_sha
-<syslog_test.ml>: use_syslog
 
 # Note: parent _tags file specifies
 #   <**/*.{byte,native}>: use_unix, use_pcre, use_sha
 # so only additions and deletions to those are needed here
 
-<control_file_test.{byte,native}>: use_syslog
-<metadata_test.{byte,native}>: use_syslog
+<control_file_test.{byte,native}>: use_bigarray, use_netsys_oothr, use_netsys
+<metadata_test.{byte,native}>: use_bigarray, use_netsys_oothr, use_netsys
 <patch_test.{byte,native}>: -use_pcre
 <sha1_test.{byte,native}>: -use_pcre
-<syslog_test.{byte,native}>: -use_pcre, -use_sha, use_syslog
diff --git a/tests/syslog_test.ml b/tests/syslog_test.ml
deleted file mode 100644
index ee5d612..0000000
--- a/tests/syslog_test.ml
+++ /dev/null
@@ -1,14 +0,0 @@
-(* approx: proxy server for Debian archive files
-   Copyright (C) 2009  Eric C. Cooper <ecc at cmu.edu>
-   Released under the GNU General Public License *)
-
-open Printf
-open Syslog
-
-let msg =
-  match Array.length Sys.argv with
-  | 1 -> eprintf "Usage: %s message ...\n" Sys.argv.(0); exit 1
-  | n -> String.concat " " (Array.to_list (Array.sub Sys.argv 1 (n - 1)))
-
-let log = openlog Sys.argv.(0)
-let () = syslog log `LOG_INFO msg

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/approx.git



More information about the Pkg-ocaml-maint-commits mailing list