You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "silver-ymz (via GitHub)" <gi...@apache.org> on 2023/08/01 09:30:06 UTC
[GitHub] [incubator-opendal] silver-ymz commented on a diff in pull request #2705: feat(bindings/haskell): support logging layer
silver-ymz commented on code in PR #2705:
URL: https://github.com/apache/incubator-opendal/pull/2705#discussion_r1280353388
##########
bindings/haskell/src/logger.rs:
##########
@@ -0,0 +1,36 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::ffi::{c_char, CString};
+
+pub struct HsLogger {
+ pub callback: extern "C" fn(*const c_char),
+}
+
+impl log::Log for HsLogger {
Review Comment:
> I don't like the idea of exposing a HsLoggerin hashell binding directly.
If you don't like exposing a `HsLogger`, we can also implement `logging` with pure haskell without any rust code. My purpose of using `HsLogger` is to reduce duplicate code and maintain consistency between rust logs and Haskell logs.
> My current understanding is:
> - Provide a HaskellLayer which implements opendal::Layer in rust.
> - HaskellLayer should expose FFI to haskell like a trait in haskell so other libs can implement it (I don't is it a thing in haskell).
> - And finnally, users can implement whatever they want in haskell.
My understanding is that `OpMonad` in haskell side provides almost same function with `HaskellLayer`. As result, it's not necessary to provide a `HaskellLayer`. Users can implement whatever they want through `OpMonad`.
> So: haskell binding itself should know nothing about logging
Users might need to integrate OpenDAL logging with their own logging system. I don't think it's a good idea.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org