-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #258 from laixintao/feature/log-config
Support config log location in iredisrc.
- Loading branch information
Showing
6 changed files
with
48 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,9 @@ | ||
import os | ||
import logging | ||
from pathlib import Path | ||
|
||
__version__ = "0.9.1" | ||
|
||
|
||
logging.basicConfig( | ||
filename=os.path.join(os.getenv("HOME"), ".iredis.log"), | ||
filemode="a", | ||
format="%(levelname)5s %(message)s", | ||
level="DEBUG", | ||
) | ||
__version__ = "0.9.1" | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.info("------ iRedis ------") | ||
|
||
project_root = Path(os.path.dirname(os.path.abspath(__file__))) | ||
project_data = project_root / "data" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import pexpect | ||
from textwrap import dedent | ||
from pathlib import Path | ||
|
||
|
||
def test_log_location_config(): | ||
config_content = dedent( | ||
""" | ||
[main] | ||
log_location = /tmp/iredis1.log | ||
""" | ||
) | ||
with open("/tmp/iredisrc", "w+") as etc_config: | ||
etc_config.write(config_content) | ||
|
||
cli = pexpect.spawn("iredis -n 15 --iredisrc /tmp/iredisrc", timeout=1) | ||
cli.expect("127.0.0.1") | ||
cli.close() | ||
|
||
log = Path("/tmp/iredis1.log") | ||
assert log.exists() | ||
with open(log, "r") as logfile: | ||
content = logfile.read() | ||
|
||
assert len(content) > 100 |