Skip to content

Commit

Permalink
ini (ini->scm): Allow to set the log driver and log options
Browse files Browse the repository at this point in the history
* modules/ini.scm (ini->scm): Allow to set the log driver and log options.
* doc/api-ini.texi: Update.
  • Loading branch information
artyom-poptsov committed Oct 11, 2023
1 parent 09fb698 commit 82ff585
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 9 additions & 2 deletions doc/api-ini.texi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This file is part of Guile-INI Reference Manual.
@c Copyright (C) 2021 Artyom V. Poptsov
@c Copyright (C) 2021-2023 Artyom V. Poptsov
@c See the file guile-ini.texi for copying conditions.

@node INI
Expand All @@ -12,10 +12,17 @@ format.
@deffn {Scheme Procedure} ini->scm @
port @
[#:read-comments?=#t] @
[#:debug-mode?=#f]
[#:debug-mode?=#f] @
[#:log-driver=#f] @
[#:log-opt='()]

Read INI data from a @var{port} and convert it to the Scheme representation.

@var{log-driver} allows to set the logging driver. Possible values are:
``syslog'' (used by default when @code{log-driver} is set to @code{#f}),
``file'', ``null''. Using @var{log-opt} parameter one can pass additional
options for a logging driver.

@end deffn

@deffn {Scheme Procedure} scm->ini @
Expand Down
8 changes: 7 additions & 1 deletion modules/ini.scm
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@
(define* (ini->scm port
#:key
(read-comments? #t)
(debug-mode? #f))
(debug-mode? #f)
(log-driver #f)
(log-opt '()))
"Read INI data from a PORT and convert it to the scheme representation."

(when log-driver
(smc-log-init! log-driver log-opt))

(let ((fsm (make <ini-fsm> #:debug-mode? debug-mode?)))
(let ((context (fsm-run! fsm (make <ini-context>
#:port port
Expand Down

0 comments on commit 82ff585

Please sign in to comment.