CiLog是一种灵活的集成测井工具,它以包测井为基础,可以替代传统测井内置打印直接。

cilog的Python项目详细描述


西洛语

CiLog是一个灵活的集成日志工具,基于包日志记录,具有颜色和自定义粗体字体。在

特色

  • 彩色控制台输出
  • 设置堆栈信息输出级别
  • 为每个级别自定义格式的简便方法
  • 替代品内置打印:一个新的打印语法使用日志!在
  • nohup cmd &替换为“task”的命令行脚本 已完成提醒”功能。在

安装

$ pip install cilog

新功能

1.1.3

  • 错误已修复

1.1.2

  • 首次运行时自动安装依赖项。在

1.1.1

  • 错误已修复

1.1.0

  • 添加原点标高。当我们使用sub_print=True时,print(f'string')将像普通的内置打印一样工作 功能。其他级别,如infodebug和{}等,应该用特殊的符号来指定 比如#IN##D#和{}等
  • 支持数据科学家以降价格式或乳胶格式打印表格。在

1.0.2

  • 错误已修复

1.0.1

  • 错误已修复

1.0.0

  • 开发打印功能替代功能。现在你可以直接 将参数sub_print=True发送到create_logger以替换print。在
  • 命令行工具:cilog现在可用!你没有 再使用nohup cmd &!它甚至会发送电子邮件给你当你的任务 完整的!请参考主要文件。在

0.3.0

  • 替代品内置打印使用logger.substitute_打印()
  • 一个全新的方式使用日志!只需使用print()!在
  • 通过使用print,您需要知道更简单的logger语法。 请参阅主要文件。在

0.2.1

  • 错误修复:现在记录器可以自动创建日志文件的目录。在

0.2.0

  • 消除ipt_信息,您可以使用重要记录()记录重要信息。在
  • 添加发送电子邮件的功能。默认情况下,在设置“启用邮件”和“邮件”设置后,所有邮件的日志 日志程序.mail()将根据邮件设置发送到特定的电子邮件地址。在

0.1.1

  • 当日志文件的行长度大于1e+4时,它将自动用localtime备份日志文件,然后使用new 日志文件。在

0.1.0

  • 新参数ipt_info

基本用途

^{pr2}$

“*”表示新功能

create_logger关键字:

名称:str-记录器名称

file:str-文件路径

文件模式:str-文件打开模式。默认值:“a”

文件级别:Literal['DEBUG','INFO','WARNING','IMPORTANT','ERROR','CRITICAL','MAIL']-默认'INFO'

enable_mail:bool-默认为False

邮件级别:Literal['DEBUG','INFO','WARNING','IMPORTANT','ERROR','CRITICAL','mail']-默认'mail'

邮件设置:dir-如果enable\u mail==True,则必需

    {
        mailhost:   string or tuple - YourMailHost or (host, port),
        fromaddr:   string          - YourSenderAddress,
        toaddrs:    list(string)    - List of YourTargetAddresses,
        subject:    string          - Mail Subject,
        credentials:tuple           - (YourUsername, YourPassword),
        secure:     tuple           - () or (KeyfileName) or (KeyfileName, CertificatefileName)
                                        use the secure protocol (TLS),
        timeout:    float           - Default 1.0
    }

use_color:bool-使用彩色信息的信号。默认为真

堆栈级别:Literal['DEBUG','INFO','WARNING','IMPORTANT','ERROR','CRITICAL','MAIL']-默认'ERROR'

msg_fmt:Dict{'DEBUG':调试\fmt,'INFO':INFO_fmt,'WARNING':WARNING_fmt,'IMPORTANT':重要的\u fmt, “ERROR”:ERROR_fmt,“CRITICAL”:关键的“MAIL”:MAIL“fmt”}-自定义设计消息格式。在

(特别是,您可以使用$BOLDtext$RESET使用粗体字体) 请参考CustomFormatter和url:https://docs.python.org/3/library/logging.html#logrecord-attributes

return:logger:CustomLogger

提前使用

替代品内置打印

你唯一应该做的是:

fromcilogimportcreate_loggercreate_logger(sub_print=True)# Then: you can even execute the following scripts # in other files if only you have run these two lines# in the same system process# Let us just try!print('i=1')# info: i=1print('i','=','1')# info: i = 1print('#D#Here!')# Debug: Here! [#d#, #DEbu#, #dEBug#, ... are all valid!]print('#W#warning')# Warning ...# Similarly, #e# #ER# ...: error, #I# #IM# ...: important,# #C# #CRE# ...: critical, #M# #MA# #Mail# ...: mail.

Grammar:使用logger.info的方法就是使用print,并且 使用其他级别是键入该级别的前几个字符 名称介于simbol#之间。在

您可以在实际使用记录器的任何地方使用print 你创建来输出!同时,你c使用任何print功能, 类似于end=*或{},但不要使用file=*,因为记录器 只监视标准输出。在

详细示例:

fromcilogimportcreate_loggerdefcall_error():print('#E#Exception')'''mail_setting = {            mailhost:   string or tuple - YourMailHost or (host, port),            fromaddr:   string          - YourSenderAddress,            toaddrs:    list(string)    - List of YourTargetAddresses,            subject:    string          - Mail Subject,            credentials:tuple           - (YourUsername, YourPassword),            secure:     tuple           - () or (KeyfileName) or (KeyfileName, CertificatefileName)                                            use the secure protocol (TLS),            timeout:    float           - Default 1.0        }'''mail_setting={'mailhost':('*****',int(**)),'fromaddr':'****@*****','toaddrs':['****@****','***@***'],'subject':'CiLog test','credentials':('***@**','****')}create_logger(name='l1',file='./log.log',enable_mail=True,mail_setting=mail_setting,sub_print=True)# The simplest usage `create_logger(sub_print=True)`print('origin')table_list=[['Tox21','Clintox'],[1,2],[3,4]]print(f'#t#{table_list}')# print table in markdown format# |   Tox21 |   Clintox |# |--------:|----------:|# |       1 |         2 |# |       3 |         4 |print(f'#t#!latex{table_list}')# latex format table# \begin{tabular}{rr}# \toprule#  Tox21 &  Clintox \\# \midrule#      1 &        2 \\#      3 &        4 \\# \bottomrule# \end{tabular}print('#IN#start')print('#D#here')print('#W#warn')call_error()print('#C#Program exit.')print('#IM#lal')# print('#M#test')

命令行用法

第一步

运行$ cilog [any cmd]在创建默认配置文件 $HOME$/.cilog/config.json然后用您的自定义修改它 设置。在

运行

例如:

$ cilog python my_algorithm.py --lr 0.01 --epoch 100

等于:

$ nohup python my_algorithm.py --lr 0.01 --epoch 100 > cilog.log 2>&1&

-e用法:

$ cilog -e python my_algorithm.py --lr 0.01 --epoch 100

与上一个示例没有不同,但将发送给您 任务完成时的电子邮件[使用默认设置]。 当你的程序很耗时时,它特别有用。在

-c [config_file]:使用您自己的配置文件,而不是默认的配置文件。在

-r [redirect_file]:将输出重定向到文件,而不是cilog.log。在

注意:不要在程序中使用相同的cmdline参数-c -e -r, 否则会导致错误。在

帮助:cilog --help

许可证

MIT LICENSE

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在某些练习中避免索引异常   java Android,如何在具有socket的网络区域上提高性能?   更改web中的执行顺序后,JavaServlet过滤器不起作用。xml   java如何绑定泛型类?   JavaGmail RESTAPI:使用Google凭证而不模拟   java是解码整数序列的最快方法   java根据hashmaps的值(通过map的值进行比较)对hashmaps的数组列表进行排序   用于JBoss 7.1或Apache的java负载平衡器,带有Healt检查   java非常慢的MySQL读取性能   java如何在使用iRetryAnalyzer时从Windows CMD关闭Selenium WebDriver?   java随机闪烁仅出现在Galaxy Note 4上   java AttributeOverride MappedSuperClass属性的类型不同   java JPA:如何检测现有实体是否已更新?   java如何使用mavenassemblyplugin从dependencySet中删除METAINF?   安装SecurityManager时,java MQQueueManager构造函数挂起