CouchDB -如何记录或捕获请求对象?

2ledvvac  于 2023-08-01  发布在  CouchDB
关注(0)|答案(1)|浏览(196)

文档表明,可以log()一个请求对象toJSON,但它不工作。
我已经在我的Couch示例上配置了info级别的日志记录,并通过_design文档进行了精心制作,我从"validate_doc_update": "function(doc, req){log(toJSON(req))}"得到的所有信息是:

[info] 2023-07-07T21:53:02.138399Z nonode@nohost <0.32001.0> -------- OS Process #Port<0.44> Log :: {"_id":"abc","_rev":"6-4ce6392348c3ad61213d15184a08c3c3","title":"There is Notaasdfhing Left to Lose","artist":"Fasdfoo Fighters","year":"129297","_revisions":{"start":6,"ids":["4ce6392348c3ad61213d15184a08c3c3","558aa6381166ee2836c112e0eac4b148","fa0362e7c84f3c0df7827515b5c58f86","a266c2261a2d0704c5fe7689b6786dfb","645dd6050dcd378678fea4627db832b3","4c6114c65e295552ab1019e2b046b10e"]}}

字符串
不包括所有记录在请求对象中的好东西?

{
   "body": "undefined",
   "cookie": {
       "AuthSession": "cm9vdDo1MDZBRjQzRjrfcuikzPRfAn-EA37FmjyfM8G8Lw",
       "m": "3234"
   },
   "form": {},
   "headers": {
       "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
       "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.3",
       "Accept-Encoding": "gzip,deflate,sdch",
       "Accept-Language": "en-US,en;q=0.8",
       "Connection": "keep-alive",
       "Cookie": "m=3234:t|3247:t|6493:t|6967:t|34e2:|18c3:t|2c69:t|5acb:t|ca3:t|c01:t|5e55:t|77cb:t|2a03:t|1d98:t|47ba:t|64b8:t|4a01:t;
AuthSession=cm9vdDo1MDZBRjQzRjrfcuikzPRfAn-EA37FmjyfM8G8Lw",
       "Host": "127.0.0.1:5984",
       "User-Agent": "Mozilla/5.0 (Windows NT 5.2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7"
   },
   "id": "foo",
   "info": {
       "committed_update_seq": 2701412,
       "compact_running": false,
       "db_name": "mailbox",
       "disk_format_version": 6,
       "doc_count": 2262757,
       "doc_del_count": 560,
       "instance_start_time": "1347601025628957",
       "purge_seq": 0,
       "sizes": {
         "active": 7580843252,
         "disk": 14325313673,
         "external": 7803423459
       },
       "update_seq": 2701412
   },
   "method": "GET",
   "path": [
       "mailbox",
       "_design",
       "request",
       "_show",
       "dump",
       "foo"
   ],
   "peer": "127.0.0.1",
   "query": {},
   "raw_path": "/mailbox/_design/request/_show/dump/foo",
   "requested_path": [
       "mailbox",
       "_design",
       "request",
       "_show",
       "dump",
       "foo"
   ],
   "secObj": {
       "admins": {
           "names": [
               "Bob"
           ],
           "roles": []
       },
       "members": {
           "names": [
               "Mike",
               "Alice"
           ],
           "roles": []
       }
   },
   "userCtx": {
       "db": "mailbox",
       "name": "Mike",
       "roles": [
           "user"
       ]
   },
   "uuid": "3184f9d1ea934e1f81a24c71bde5c168"
}

whitzsjs

whitzsjs1#

我认为你混淆了复制过滤器函数和validate_doc_update函数。对后者的调用并没有给出请求对象,按照文档,它给出了新文档、旧文档(您正在记录的内容)、用户上下文和安全对象。

相关问题