Skip to content

Conversation

@6unYoung
Copy link
Contributor

@6unYoung 6unYoung commented Nov 19, 2025

πŸ”— Related Issue

⌨️ What I did

  • cmdlog filter λͺ…령을 μ²˜λ¦¬ν•˜λŠ” process_cmdlog_filter() ν•¨μˆ˜λ₯Ό μΆ”κ°€ν–ˆμŠ΅λ‹ˆλ‹€.
  • 필터링 검사λ₯Ό μˆ˜ν–‰ν•˜λŠ” is_cmdlog_filter_match() ν•¨μˆ˜λ₯Ό μΆ”κ°€ν–ˆμŠ΅λ‹ˆλ‹€.
  • cmdlog_write()κ°€ κΈ°μ‘΄κ³Ό λ™μΌν•œ λ™μž‘μ„ ν•˜κ²Œλ” command에 λŒ€ν•œ λ‘œμ§μ„ μˆ˜μ •ν–ˆμŠ΅λ‹ˆλ‹€.
  • cmdlog_add(), cmdlog_remove(), cmdlog_list() ν•¨μˆ˜λ₯Ό μΆ”κ°€ν–ˆμŠ΅λ‹ˆλ‹€.
  • cmd_log_global의 멀버 λ³€μˆ˜λ‘œ ν•„ν„° 리슀트 struct cmd_log_filter filters[CMDLOG_FILTER_MAXNUM]을 μΆ”κ°€ν–ˆμŠ΅λ‹ˆλ‹€.

λͺ…μ„Έ

  1. ν•„ν„° μΆ”κ°€ λͺ…λ Ήμ–΄
    cmdlog filter add [command <cmd>] [key <key>]둜 ν•„ν„°λ₯Ό λ“±λ‘ν•œλ‹€. command, key μ˜΅μ…˜ 쀑 ν•˜λ‚˜λŠ” μƒλž΅ν•  수 μžˆλ‹€. μƒλž΅λœ μ˜΅μ…˜μ€ ν•„ν„°λ§ν•˜μ§€ μ•ŠλŠ”λ‹€. 문자 μœ νš¨μ„± κ²€μ‚¬λŠ” μˆ˜ν–‰ν•˜μ§€λ§Œ, λͺ…령어와 ν‚€μ˜ 쑴재 μ—¬λΆ€λ₯Ό κ²€μ‚¬ν•˜μ§„ μ•ŠλŠ”λ‹€. ν•„ν„° μˆ˜μ—λŠ” μ œν•œμ΄ μ‘΄μž¬ν•œλ‹€.
μ˜ˆμ‹œ
$ cmdlog start
$ cmdlog filter add command add key 01
    0. Filter: command = add, key = 01
$ add 01 0 0 2  // λ‘œκΉ…
$ add 01:02 0 5 1  // λ‘œκΉ…x(ν‚€ 뢈일치)

$ cmdlog filter add command bop_insert
    1. Filter: command = bop_insert, key =
$ bop insert  // ν•„ν„°κ°€ μΌμΉ˜ν•΄ λͺ…λ Ήμ˜ 결과와 상관없이 λ‘œκΉ…
    CLIENT_ERROR bad command line format

// μ˜΅μ…˜ λͺ¨λ‘ μƒλž΅ μ‹œ μ—λŸ¬
$ cmdlog filter add
    CLIENT_ERROR bad command line format

// νŒŒλΌλ―Έν„°κ°€ μœ νš¨ν•œμ§€ 검사
$ cmdlog filter add key \t\n
    CLIENT_ERROR bad command line format
$ cmdlog filter add command add key
    CLIENT_ERROR bad command line format
$ cmdlog filter add key a:b:d!#-^
    2. Filter: command = , key = a:b:d!#-^

// 단 νŒŒλΌλ―Έν„°μ˜ 쑴재 μ—¬λΆ€λ₯Ό κ²€μ‚¬ν•˜μ§„ μ•ŠμŒ
$ cmdlog filter add command dumm1
    2. Filter: command = dumm1, key =

// ν•„ν„° μ΅œλŒ€ κ°œμˆ˜μ— μ œν•œ 쑴재
$ cmdlog filter add key a
    3. Filter: command = , key = a
...
$ cmdlog filter add key b
    CLIENT_ERROR filter list is full
  1. ν•„ν„° μ‚­μ œ λͺ…λ Ήμ–΄
    cmdlog filter remove (index)둜 ν•„ν„°λ₯Ό μ‚­μ œν•œλ‹€. 인덱슀λ₯Ό μž…λ ₯ν•˜λ©΄ μ°Ύμ•„ μ‚­μ œν•˜κ³ , μƒλž΅ μ‹œ λͺ¨λ“  ν•„ν„°λ₯Ό μ‚­μ œν•œλ‹€.
μ˜ˆμ‹œ
$ cmdlog filter remove 99
    CLIENT_ERROR  invalid parameters
$ cmdlog filter remove 2
    1 filters removed
$ cmdlog filter remove
    9 filters removed
  1. ν•„ν„° 좜λ ₯ λͺ…λ Ήμ–΄
    cmdlog filter list둜 ν•„ν„° λͺ©λ‘μ„ 좜λ ₯ν•œλ‹€. ν˜„μž¬ ν•„ν„° μˆ˜μ™€ μ΅œλŒ€ ν•„ν„° 수λ₯Ό 같이 좜λ ₯ν•œλ‹€.
μ˜ˆμ‹œ
$ cmdlog filter list
    (2/10)
    1. command=     key=01
    2. command=add  key=02:02

@6unYoung 6unYoung force-pushed the feature_cmdlog branch 2 times, most recently from 3a75cc0 to 5ceae4f Compare November 19, 2025 09:00
@6unYoung
Copy link
Contributor Author

6unYoung commented Nov 20, 2025

의견이 ν•„μš”ν•œ 뢀뢄이 λͺ‡ 개 μžˆμ–΄ 확인 λΆ€νƒλ“œλ¦½λ‹ˆλ‹€.

  1. ν•„ν„° μΆ”κ°€ μ‹œ ν‚€λ₯Ό λ¬΄μ‹œν•˜κ±°λ‚˜ ν•„μš”λ‘œ ν•˜μ§€ μ•ŠλŠ” λͺ…λ Ή(mget, flush, help, ..)에 λŒ€ν•΄ μž„μ˜λ‘œ ν‚€λ₯Ό 같이 넣은 경우, λͺ…λ Ήμ–΄κ°€ μ‹€μ œλ‘œ μž…λ ₯될 λ•Œ ν‚€λ₯Ό ν•„μš”λ‘œ ν•˜μ§€ μ•ŠλŠ” λͺ…령에 λŒ€ν•΄ ν‚€λ₯Ό nul둜 μ²˜λ¦¬ν•˜λ―€λ‘œ ν•΄λ‹Ή ν•„ν„°λŠ” μ ˆλŒ€ λ§€μΉ­λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. 이런 κ²½μš°μ— λŒ€ν•΄ ν‚€λ₯Ό μž…λ ₯ν•˜μ§€ λͺ»ν•˜λ„둝 λ°©μ–΄ μ½”λ“œκ°€ ν•„μš”ν• κΉŒμš”?

  2. ν•„ν„°λ₯Ό λ™μ μœΌλ‘œ λ³€κ²½ν•˜λŠ” κΈ°λŠ₯은 없어도 λœλ‹€κ³  ν•˜μ…¨λŠ”λ°, 동적 변경을 λ§‰μœΌλ €κ³  ν•˜λ©΄ μ½”λ“œκ°€ λ‹€μ†Œ μ§€μ €λΆ„ν•΄μ§ˆ 것 κ°™μŠ΅λ‹ˆλ‹€.
    κΈ°μ‘΄ μ½”λ“œμ—μ„œλŠ” process_cmdlog_command()μ—μ„œ cmdlog_start()등을 ν˜ΈμΆœν•  λ•Œ already_check λ³€μˆ˜λ₯Ό 인자둜 λ„˜κ²¨ cmdlog.c에 μ‘΄μž¬ν•˜λŠ” cmdlog_in_use의 true/false 여뢀에 따라 μ—λŸ¬ 처리λ₯Ό ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. 그런데 filter κΈ°λŠ₯은 λ³„λ„μ˜ subcommandλ₯Ό μš”κ΅¬ν•˜λ―€λ‘œ process_cmdlog_filter()λ₯Ό λ§Œλ“€μ–΄ cmdlog_filter_add()등을 ν˜ΈμΆœν•˜κ²Œ ν–ˆμŠ΅λ‹ˆλ‹€. λ”°λΌμ„œ κΈ°μ‘΄ μ½”λ“œμ™€ 같은 λ ˆλ²¨μ—μ„œ μ—λŸ¬ 핸듀링도 μ•ˆλ˜κ³ , 리턴 μ½”λ“œλ‘œ λ„˜κΈ°κΈ°μ—λ„ μ’‹μ§„ μ•Šμ•„ λ³΄μž…λ‹ˆλ‹€.
    κ·Έλž˜μ„œ 일단 동적 변경을 ν—ˆμš©ν•˜κ²Œ ν–ˆλŠ”λ°, κΈ°λŠ₯적으둜 λ¬Έμ œκ°€ λ κΉŒμš”?

@ing-eoking
Copy link
Collaborator

개인 μ˜κ²¬μž…λ‹ˆλ‹€.

ν•„ν„° μΆ”κ°€ μ‹œ ν‚€λ₯Ό λ¬΄μ‹œν•˜κ±°λ‚˜ ν•„μš”λ‘œ ν•˜μ§€ μ•ŠλŠ” λͺ…λ Ή(mget, flush, help, ..)에 λŒ€ν•΄ μž„μ˜λ‘œ ν‚€λ₯Ό 같이 넣은 경우, λͺ…λ Ήμ–΄κ°€ μ‹€μ œλ‘œ μž…λ ₯될 λ•Œ ν‚€λ₯Ό ν•„μš”λ‘œ ν•˜μ§€ μ•ŠλŠ” λͺ…령에 λŒ€ν•΄ ν‚€λ₯Ό nul둜 μ²˜λ¦¬ν•˜λ―€λ‘œ ν•΄λ‹Ή ν•„ν„°λŠ” μ ˆλŒ€ λ§€μΉ­λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. 이런 κ²½μš°μ— λŒ€ν•΄ ν‚€λ₯Ό μž…λ ₯ν•˜μ§€ λͺ»ν•˜λ„둝 λ°©μ–΄ μ½”λ“œκ°€ ν•„μš”ν• κΉŒμš”?

이 κ²½μš°λŠ” μ‚¬μš©μžκ°€ 잘λͺ» 넣은 κ²½μš°μ— ν•΄λ‹Ήν•˜λ―€λ‘œ 별닀λ₯Έ 처리λ₯Ό ν•  ν•„μš”κ°€ 없을 것 κ°™μŠ΅λ‹ˆλ‹€.
ν•„ν„° 쑰건에 λͺ…λ Ήμ–΄λ₯Ό μ—†λŠ” λͺ…λ Ήμ–΄λ₯Ό λ„£λŠ” κ²½μš°μ™€ μœ μ‚¬ν•˜μ§€ μ•Šμ„κΉŒ μƒκ°λ©λ‹ˆλ‹€. (ex. cmd=abcdef)

ν•„ν„°λ₯Ό λ™μ μœΌλ‘œ λ³€κ²½ν•˜λŠ” κΈ°λŠ₯은 없어도 λœλ‹€κ³  ν•˜μ…¨λŠ”λ°, 동적 변경을 λ§‰μœΌλ €κ³  ν•˜λ©΄ μ½”λ“œκ°€ λ‹€μ†Œ μ§€μ €λΆ„ν•΄μ§ˆ 것 κ°™μŠ΅λ‹ˆλ‹€.
κΈ°μ‘΄ μ½”λ“œμ—μ„œλŠ” process_cmdlog_command()μ—μ„œ cmdlog_start()등을 ν˜ΈμΆœν•  λ•Œ already_check λ³€μˆ˜λ₯Ό 인자둜 λ„˜κ²¨ cmdlog.c에 μ‘΄μž¬ν•˜λŠ” cmdlog_in_use의 true/false 여뢀에 따라 μ—λŸ¬ 처리λ₯Ό ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. 그런데 filter κΈ°λŠ₯은 λ³„λ„μ˜ subcommandλ₯Ό μš”κ΅¬ν•˜λ―€λ‘œ process_cmdlog_filter()λ₯Ό λ§Œλ“€μ–΄ cmdlog_filter_add()등을 ν˜ΈμΆœν•˜κ²Œ ν–ˆμŠ΅λ‹ˆλ‹€. λ”°λΌμ„œ κΈ°μ‘΄ μ½”λ“œμ™€ 같은 λ ˆλ²¨μ—μ„œ μ—λŸ¬ 핸듀링도 μ•ˆλ˜κ³ , 리턴 μ½”λ“œλ‘œ λ„˜κΈ°κΈ°μ—λ„ μ’‹μ§„ μ•Šμ•„ λ³΄μž…λ‹ˆλ‹€. κ·Έλž˜μ„œ 일단 동적 변경을 ν—ˆμš©ν•˜κ²Œ ν–ˆλŠ”λ°, κΈ°λŠ₯적으둜 λ¬Έμ œκ°€ λ κΉŒμš”?

λ™μ μœΌλ‘œ λ³€κ²½λ˜μ–΄λ„ 상관없을 것 κ°™μŠ΅λ‹ˆλ‹€.

@ing-eoking ing-eoking self-requested a review November 20, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants