← 返回 rippling 的题目列表Configurable Logger With Message Transformations and Storage
类型:online_judge
Problem: Implement a Configurable Logger (Transformations + Storage)
Implement a Logger (or equivalent interface) that can apply the following operations to an input log message. Each feature should be demonstrable by printing output or showing the logger behavior after operations.
Requirements
For each input string message, the logger should support enabling/disabling these capabilities:
Remove: Before printing, remove all occurrences of a configured string pattern from the message.
Truncate: Before printing, truncate the message to at most maxLen characters.
Capitalize: Before printing, convert the entire message to uppercase.
Store-only: Store the processed message in an internal list storedMessages but do not print it.
I/O and Constraints (Interview Style)
You may design the class/method signatures (e.g., log(message), configure(...)).
You must be able to demonstrate different configuration combinations and the resulting printed output and/or stored messages.
Features may be combined (e.g., remove + truncate + capitalize).
Example (Illustrative)
Config: remove="abc", truncate=5, capitalize=true, storeOnly=false
Input: "xxabcyyabczz"
After remove: "xxyyzz", truncate to 5: "xxyyz", uppercase: "XXYYZ", then print "XXYYZ".
Example
Input
remove=abc;truncate=5;capitalize=1;storeOnly=0
xxabcyyabczz
Output
XXYYZ