forked from 7max/log4cl
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
log4cl syslog: don't require cffi when unnecessary
We create a separate system for this functionality. Also, if implementation has its native support for syslog - use it. SBCL for now. Moreover we remove ABCL hack (since it is a separate system, then if cffi fails to load – it's OK – system won't load anyway).
- Loading branch information
1 parent
1c77374
commit 5c6f819
Showing
4 changed files
with
75 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- | ||
;;; | ||
;;; Copyright (c) 2013, 2014, Jan Moringen. All rights reserved. | ||
;;; | ||
;;; License: Apache-2.0 | ||
;;; | ||
(in-package #:log4cl) | ||
|
||
(defmethod appender-do-append ((appender syslog-appender) logger level log-func) | ||
(let* ((syslog-level (%log4cl-level->syslog-level level)) | ||
(layout (appender-layout appender)) | ||
(message | ||
(with-output-to-string (stream) | ||
(layout-to-stream layout stream logger level log-func)))) | ||
(cl-syslog:log (syslog-appender-name appender) :user syslog-level message | ||
(if (syslog-appender-include-pid? appender) | ||
cl-syslog:+log-pid+ 0)))) | ||
|
||
|
||
;; Utility functions | ||
|
||
(defun %log4cl-level->syslog-level (level) | ||
(let ((level/keyword (aref +log-level-to-keyword+ level))) | ||
(ecase level/keyword | ||
(:fatal :crit) | ||
(:error :err) | ||
(:warn :warning) | ||
(:info :info) | ||
((:debu1 :debu2 :debu3 :debu4 :debu5 :debu6 :debu7 :debu8 :debu9) | ||
:debug)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- | ||
;;; | ||
;;; Copyright (c) 2013, 2014, Jan Moringen. All rights reserved. | ||
;;; | ||
;;; License: Apache-2.0 | ||
;;; | ||
(in-package #:log4cl) | ||
|
||
(defmethod appender-do-append ((appender syslog-appender) logger level log-func) | ||
(let* ((syslog-level (%log4cl-level->syslog-level level)) | ||
(layout (appender-layout appender)) | ||
(message | ||
(with-output-to-string (stream) | ||
(layout-to-stream layout stream logger level log-func)))) | ||
(sb-posix:openlog (syslog-appender-name appender) | ||
(logior sb-posix:log-user | ||
(if (syslog-appender-include-pid? appender) | ||
sb-posix:log-pid 0))) | ||
(sb-posix:syslog syslog-level "~A" message) | ||
(sb-posix:closelog))) | ||
|
||
;; Utility functions | ||
|
||
(defun %log4cl-level->syslog-level (level) | ||
(let ((level/keyword (aref +log-level-to-keyword+ level))) | ||
(ecase level/keyword | ||
(:fatal sb-posix:log-crit) | ||
(:error sb-posix:log-err) | ||
(:warn sb-posix:log-warning) | ||
(:info sb-posix:log-info) | ||
((:debu1 :debu2 :debu3 :debu4 :debu5 :debu6 :debu7 :debu8 :debu9) | ||
sb-posix:log-debug)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters