


技术领域technical field
本公开属于计算机技术领域,具体涉及一种日志打印方法及装置、电子设备和计算机可读存储介质。The present disclosure belongs to the field of computer technology, and in particular relates to a log printing method and device, an electronic device, and a computer-readable storage medium.
背景技术Background technique
在如今的嵌入式软件系统中,通常都有很多任务在执行,执行的顺序是按照任务的优先级从高到低。这些任务中,有一些日志需要通过嵌入式系统中的硬件接口打印到外部,开发人员利用这些日志了解系统内部的运行状态。然而,打印日志这个操作本身会占用一定的时间,如果不对打印操作进行有效的规划,无序的日志打印操作会对系统的其它任务带来影响,轻则响应变慢,重则导致系统无法正常工作。In today's embedded software systems, there are usually many tasks being executed, and the order of execution is from high to low according to the priority of the tasks. Among these tasks, some logs need to be printed to the outside through the hardware interface in the embedded system, and developers use these logs to understand the internal running status of the system. However, the operation of printing the log itself will take a certain amount of time. If the printing operation is not effectively planned, the disordered log printing operation will have an impact on other tasks of the system, and the response will be slowed down, and the system will not be able to work normally. Work.
发明内容SUMMARY OF THE INVENTION
本公开旨在至少解决现有技术中存在的技术问题之一,提供一种日志打印方法及装置、电子设备和计算机可读存储介质。The present disclosure aims to at least solve one of the technical problems existing in the prior art, and provides a log printing method and apparatus, an electronic device, and a computer-readable storage medium.
本公开的一方面,提供一种日志打印方法,所述方法包括:An aspect of the present disclosure provides a log printing method, the method comprising:
建立打印任务,所述打印任务包括打印标识组件和压缩标识组件;其中,所述打印标识组件用于指示压缩前的待打印日志的总长度、打印开始位置以及打印结束位置,所述压缩标识组件用于指示压缩进度信息;A printing task is established, the printing task includes a printing identification component and a compression identification component; wherein, the printing identification component is used to indicate the total length of the log to be printed before compression, the printing start position and the printing end position, and the compression identification component Used to indicate compression progress information;
响应于其它任务有需要打印的日志,通过调用所述打印任务的接口函数通知所述打印任务,根据所述打印标识组件的指示对所述压缩前的待打印日志进行压缩,并更新所述压缩标识组件的压缩进度信息;In response to other tasks having logs that need to be printed, notify the printing task by calling the interface function of the printing task, compress the log to be printed before compression according to the instruction of the printing identification component, and update the compression Identifies the compression progress information of the component;
响应于所述压缩标识组件指示的压缩进度信息为压缩完成信息,对压缩后的待打印日志进行打印;In response to the compression progress information indicated by the compression identification component being compression completion information, printing the compressed log to be printed;
输出打印完成的日志内容。Outputs the log content after printing is completed.
在一些实施方式中,所述打印任务还包括第一存储空间组件和第二存储空间组件;In some embodiments, the printing task further includes a first storage space component and a second storage space component;
所述第一存储空间组件用于存储其它任务的压缩前的待打印日志;The first storage space component is used to store logs to be printed before compression of other tasks;
所述第二存储空间组件用于存储其它任务的压缩后的待打印日志。The second storage space component is used for storing compressed logs to be printed of other tasks.
在一些实施方式中,所述第一存储空间组件采用循环存储的方式存储所述其它任务的压缩前的待打印日志;和/或,In some embodiments, the first storage space component stores the logs to be printed before compression of the other tasks in a circular storage manner; and/or,
所述第二存储空间组件采用循环存储的方式存储所述其它任务的压缩后的待打印日志。The second storage space component stores the compressed logs to be printed of the other tasks in a circular storage manner.
在一些实施方式中,所述方法还包括:In some embodiments, the method further includes:
设定打印任务的优先级低于所述其它任务的优先级;setting the priority of the print task to be lower than the priority of the other tasks;
响应于在执行所述打印任务的过程中,需开始执行其它任务并通知有新的日志需要打印时,则中断当前的打印任务,存储新的待打印日志以及更新打印任务中的所述打印标识组件。In response to the process of executing the printing task, when other tasks need to be executed and a new log needs to be printed, the current printing task is interrupted, the new log to be printed is stored, and the printing identification in the printing task is updated. components.
在一些实施方式中,所述根据所述打印标识组件的指示对所述压缩前的待打印日志进行压缩,包括:In some embodiments, compressing the log to be printed before compression according to the instruction of the printing identification component includes:
根据所述打印标识组件的指示,判断所述待打印日志的总长度是否大于预设压缩阈值;According to the instruction of the printing identification component, determine whether the total length of the log to be printed is greater than a preset compression threshold;
响应于所述待打印日志的总长度大于所述压缩阈值,则分次压缩所述待打印日志。In response to the total length of the log to be printed is greater than the compression threshold, the log to be printed is compressed in stages.
在一些实施方式中,所述压缩标识组件包括压缩完成标识和压缩进度标识;In some embodiments, the compression indicator component includes a compression completion indicator and a compression progress indicator;
所述更新所述压缩标识组件的压缩进度信息,包括:The updating of the compression progress information of the compression identification component includes:
根据待压缩总数和压缩完成数量,更新所述压缩进度标识;以及,Update the compression progress indicator according to the total number to be compressed and the number of completed compressions; and,
在压缩完成时,将所述压缩完成标识设置为第一预设值,未完成时,将所述压缩完成标识设置为第二预设值。When the compression is completed, the compression completion flag is set to a first preset value, and when the compression is not completed, the compression completion flag is set to a second preset value.
在一些实施方式中,所述输出打印完成的日志内容,包括:In some implementations, the outputting of the log content after printing includes:
通过直接调用寄存器的读写函数,输出打印完成的日志内容。By directly calling the read and write functions of the register, output the log content after printing.
本公开的另一方面,提供一种日志打印装置,所述装置包括:Another aspect of the present disclosure provides a log printing device, the device comprising:
建立模块,用于建立打印任务,所述打印任务包括打印标识组件和压缩标识组件;其中,所述打印标识组件用于指示压缩前的待打印日志的总长度、打印开始位置以及打印结束位置,所述压缩标识组件用于指示压缩进度信息;The establishment module is used to establish a printing task, and the printing task includes a printing identification component and a compression identification component; wherein, the printing identification component is used to indicate the total length of the log to be printed before the compression, the printing start position and the printing end position, The compression identification component is used to indicate compression progress information;
压缩模块,用于响应于其它任务有需要打印的日志,通过调用所述打印任务的接口函数通知所述打印任务,根据所述打印标识组件的指示对所述压缩前的待打印日志进行压缩,并更新所述压缩标识组件的压缩进度信息;a compression module, configured to notify the printing task by invoking the interface function of the printing task in response to a log that needs to be printed in other tasks, and compress the log to be printed before the compression according to the instruction of the printing identification component, and update the compression progress information of the compression identification component;
打印模块,用于响应于所述压缩标识组件指示的压缩进度信息为压缩完成信息,对压缩后的待打印日志进行打印;a printing module, configured to print the compressed log to be printed in response to the compression progress information indicated by the compression identification component being the compression completion information;
输出模块,用于输出打印完成的日志内容。The output module is used to output the log content after printing.
在一些实施方式中,所述打印任务还包括第一存储空间组件和第二存储空间组件;In some embodiments, the printing task further includes a first storage space component and a second storage space component;
所述第一存储空间组件用于存储其它任务的压缩前的待打印日志;The first storage space component is used to store logs to be printed before compression of other tasks;
所述第二存储空间组件用于存储其它任务的压缩后的待打印日志。The second storage space component is used for storing compressed logs to be printed of other tasks.
在一些实施方式中,所述第一存储空间组件采用循环存储的方式存储所述其它任务的压缩前的待打印日志;和/或,In some embodiments, the first storage space component stores the logs to be printed before compression of the other tasks in a circular storage manner; and/or,
所述第二存储空间组件采用循环存储的方式存储所述其它任务的压缩后的待打印日志。The second storage space component stores the compressed logs to be printed of the other tasks in a circular storage manner.
在一些实施方式中,所述装置还包括:In some embodiments, the apparatus further comprises:
设定模块,用于设定打印任务的优先级低于所述其它任务的优先级;a setting module, configured to set the priority of the printing task to be lower than the priority of the other tasks;
所述打印模块,还用于响应于在执行所述打印任务的过程中,需开始执行其它任务并通知有新的日志需要打印时,则中断当前的打印任务,存储新的待打印日志以及更新打印任务中的所述打印标识组件。The printing module is also configured to interrupt the current printing task, store the new log to be printed and update the log when it is required to start executing other tasks and notify that a new log needs to be printed in the process of executing the printing task. The print identification component in the print job.
在一些实施方式中,所述压缩模块,具体还用于:In some embodiments, the compression module is further used for:
根据所述打印标识组件的指示,判断所述待打印日志的总长度是否大于预设压缩阈值;According to the instruction of the printing identification component, determine whether the total length of the log to be printed is greater than a preset compression threshold;
响应于所述待打印日志的总长度大于所述压缩阈值,则分次压缩所述待打印日志。In response to the total length of the log to be printed is greater than the compression threshold, the log to be printed is compressed in stages.
在一些实施方式中,所述压缩标识组件包括压缩完成标识和压缩进度标识;In some embodiments, the compression indicator component includes a compression completion indicator and a compression progress indicator;
所述压缩模块,具体还用于:The compression module is also specifically used for:
根据待压缩总数和压缩完成数量,更新所述压缩进度标识;以及,Update the compression progress indicator according to the total number to be compressed and the number of completed compressions; and,
在压缩完成时,将所述压缩完成标识设置为第一预设值,未完成时,将所述压缩完成标识设置为第二预设值。When the compression is completed, the compression completion flag is set to a first preset value, and when the compression is not completed, the compression completion flag is set to a second preset value.
在一些实施方式中,所述输出模块,具体还用于:In some embodiments, the output module is further used for:
通过直接调用寄存器的读写函数,输出打印完成的日志内容。By directly calling the read and write functions of the register, output the log content after printing.
本公开的另一方面,提供一种电子设备,包括:Another aspect of the present disclosure provides an electronic device, comprising:
一个或多个处理器;one or more processors;
存储单元,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行时,能使得所述一个或多个处理器实现根据前文记载的所述的方法。A storage unit for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors can implement the above-mentioned method.
本公开的另一方面,提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时能实现根据前文记载的所述的方法。Another aspect of the present disclosure provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the method according to the foregoing description can be implemented.
本公开的日志打印方法及装置、电子设备和计算机可读存储介质,通过设置打印标识组件和压缩标识组件,将待打印日志进行有效规划,并且在待打印日志进行打印前,先对该待打印日志进行压缩,然后对压缩后的待打印日志进行打印,可以极大提高日志打印效率,减少日志打印消耗的时间,避免由于打印操作耗时长而导致的问题。The log printing method and device, electronic device and computer-readable storage medium of the present disclosure effectively plan the log to be printed by setting the printing identification component and the compressed identification component, and before printing the log to be printed, the log to be printed is firstly printed. Compressing the log and then printing the compressed log to be printed can greatly improve the efficiency of log printing, reduce the time consumed by log printing, and avoid problems caused by long printing operations.
附图说明Description of drawings
图1为本公开一实施例的电子设备的组成示意框图FIG. 1 is a schematic block diagram of the composition of an electronic device according to an embodiment of the disclosure
图2为本公开另一实施例的日志打印方法的流程图;2 is a flowchart of a log printing method according to another embodiment of the present disclosure;
图3为本公开另一实施例的日志打印系统的结构示意图。FIG. 3 is a schematic structural diagram of a log printing system according to another embodiment of the disclosure.
具体实施方式Detailed ways
为使本领域技术人员更好地理解本公开的技术方案,下面结合附图和具体实施方式对本公开作进一步详细描述。In order to make those skilled in the art better understand the technical solutions of the present disclosure, the present disclosure will be further described in detail below with reference to the accompanying drawings and specific embodiments.
首先,参照图1来描述用于实现本公开实施例的装置及方法的示例电子设备。First, an example electronic device for implementing the apparatus and method of an embodiment of the present disclosure is described with reference to FIG. 1 .
如图1所示,电子设备100包括一个或多个处理器110、一个或多个存储装置120、一个或多个输入装置130、一个或多个输出装置140等,这些组件通过总线系统150和/或其他形式的连接机构互连。应当注意,图1所示的电子设备的组件和结构只是示例性的,而非限制性的,根据需要,电子设备也可以具有其他组件和结构。As shown in FIG. 1 , the
处理器110可以是中央处理单元(CPU),或者,也可以是其它具有数据处理能力和/或指令执行能力的其他形式的处理单元,并且可以控制电子设备100中的其他组件以执行期望的功能。The processor 110 may be a central processing unit (CPU), or may be other forms of processing units with data processing capabilities and/or instruction execution capabilities, and may control other components in the
存储装置120可以包括一个或多个计算机程序产品,所述计算机程序产品可以包括各种形式的计算机可读存储介质,例如易失性存储器和/或非易失性存储器。所述易失性存储器例如可以包括随机存取存储器(RAM)和/或高速缓冲存储器(cache)等。所述非易失性存储器例如可以包括只读存储器(ROM)、硬盘、闪存等。在所述计算机可读存储介质上可以存储一个或多个计算机程序指令,处理器可以运行所述程序指令,以实现下文所述的本公开实施例中(由处理器实现)的客户端功能以及/或者其他期望的功能。在所述计算机可读存储介质中还可以存储各种应用程序和各种数据,例如,所述应用程序使用和/或产生的各种数据等。Storage 120 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and/or cache memory, or the like. The non-volatile memory may include, for example, read only memory (ROM), hard disk, flash memory, and the like. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor may execute the program instructions to implement the client functions (implemented by the processor) in the embodiments of the present disclosure described below and / or other desired functionality. Various application programs and various data, for example, various data used and/or generated by the application program, etc. may also be stored in the computer-readable storage medium.
输入装置130可以是用户用来输入指令的装置,并且可以包括键盘、鼠标、麦克风和触摸屏等中的一个或多个。The input device 130 may be a device used by a user to input instructions, and may include one or more of a keyboard, a mouse, a microphone, a touch screen, and the like.
输出装置140可以向外部(例如用户)输出各种信息(例如图像或声音),并且可以包括显示器、扬声器等中的一个或多个。The output device 140 may output various information (eg, images or sounds) to the outside (eg, a user), and may include one or more of a display, a speaker, and the like.
下面,将参考图2描述根据本公开一实施例的日志打印方法S200,该方法可以应用于嵌入式软件系统。Hereinafter, a log printing method S200 according to an embodiment of the present disclosure will be described with reference to FIG. 2 , and the method may be applied to an embedded software system.
具体地,如图2所示,一种日志打印方法S200,包括:Specifically, as shown in FIG. 2, a log printing method S200 includes:
步骤S210、建立打印任务,所述打印任务包括打印标识组件和压缩标识组件;其中,所述打印标识组件用于指示压缩前的待打印日志的总长度、打印开始位置以及打印结束位置,所述压缩标识组件用于指示压缩进度信息。Step S210, establishing a printing task, the printing task includes a printing identification component and a compression identification component; wherein, the printing identification component is used to indicate the total length of the log to be printed before compression, the printing start position and the printing end position, the The Compression ID component is used to indicate compression progress information.
具体地,在本步骤中,打印标识组件中,待打印日志的总长度指的是打印的字符串长度,可以用字节表示。待打印日志的打印开始位置和打印结束位置指的是待打印日志在空间里的位置,从0开始,到X-1(其中的X为存储空间的大小)结束。压缩标识组件也可以用字节表示压缩进度,如压缩完成时采用1表示,压缩未完成时采用0表示等等。Specifically, in this step, in the printing identification component, the total length of the log to be printed refers to the length of the printed character string, which can be expressed in bytes. The print start position and print end position of the log to be printed refer to the position of the log to be printed in the space, starting from 0 and ending at X-1 (where X is the size of the storage space). The compression identification component can also use bytes to indicate the compression progress, such as 1 when the compression is completed, 0 when the compression is not completed, and so on.
步骤S220、响应于其它任务有需要打印的日志,通过调用所述打印任务的接口函数通知所述打印任务,根据所述打印标识组件的指示对所述压缩前的待打印日志进行压缩,并更新所述压缩标识组件的压缩进度信息。Step S220, in response to other tasks having a log that needs to be printed, notify the printing task by calling the interface function of the printing task, compress the log to be printed before the compression according to the instruction of the printing identification component, and update the log to be printed. Compression progress information of the compression identification component.
具体地,在本步骤中,当其它任务有需要打印的待打印日志时,通过调用打印任务的接口函数,来通知打印任务,待打印日志的总长度和内容。当打印任务运行时,会检测当前待打印日志的长度是否为零;如果不为零,则对待打印日志进行压缩,并更新压缩标识组件的压缩进度信息,如该压缩进度信息可以包括压缩是否完成,以及压缩当前的进度,如压缩完成几个等等。Specifically, in this step, when other tasks have logs to be printed that need to be printed, the printing task is notified of the total length and content of the logs to be printed by calling the interface function of the printing task. When the printing task is running, it will detect whether the length of the current log to be printed is zero; if it is not zero, the log to be printed will be compressed, and the compression progress information of the compression identification component will be updated. For example, the compression progress information may include whether the compression is completed. , as well as the current progress of the compression, such as the completion of the compression and so on.
步骤S230、响应于所述压缩标识组件指示的压缩进度信息为压缩完成信息,对压缩后的待打印日志进行打印。Step S230, in response to the compression progress information indicated by the compression identification component being compression completion information, print the compressed log to be printed.
步骤S240、输出打印完成的日志内容。Step S240 , outputting the log content after printing is completed.
具体地,在本步骤中,输出打印完成的日志内容到外部设备。外部设备对收到的日志解压后就可以正常查看日志的内容了。Specifically, in this step, the printed log content is output to an external device. After the external device decompresses the received log, the content of the log can be viewed normally.
本实施例的日志打印方法,通过设置打印标识组件和压缩标识组件,将待打印日志进行有效规划,并且在待打印日志进行打印前,先对该待打印日志进行压缩,然后对压缩后的待打印日志进行打印,可以极大提高日志打印效率,减少日志打印消耗的时间,避免由于打印操作耗时长而导致的问题。In the log printing method of this embodiment, the log to be printed is effectively planned by setting the print identification component and the compression identification component, and before the log to be printed is printed, the log to be printed is first compressed, and then the compressed log to be printed is compressed. Printing logs for printing can greatly improve the efficiency of log printing, reduce the time consumed by log printing, and avoid problems caused by long printing operations.
在一些实施方式中,所述打印任务还包括第一存储空间组件和第二存储空间组件。所述第一存储空间组件用于存储其它任务的压缩前的待打印日志。所述第二存储空间组件用于存储其它任务的压缩后的待打印日志。In some embodiments, the print job further includes a first storage space component and a second storage space component. The first storage space component is used for storing logs to be printed before compression of other tasks. The second storage space component is used for storing compressed logs to be printed of other tasks.
具体地,在本实施方式中,存储空间组件是程序内部的空间,一般为静态随机存取存储器(Static Random-Access Memory,SRAM),当然,除此以外,该存储空间也可以选择其它一些形式的存储空间,本实施例对此并不限制。Specifically, in this embodiment, the storage space component is the space inside the program, which is generally a static random-access memory (Static Random-Access Memory, SRAM). Of course, in addition to this, the storage space can also choose other forms This embodiment does not limit the storage space.
在一些实施方式中,所述第一存储空间组件采用循环存储的方式存储所述其它任务的压缩前的待打印日志;和/或,In some embodiments, the first storage space component stores the logs to be printed before compression of the other tasks in a circular storage manner; and/or,
所述第二存储空间组件采用循环存储的方式存储所述其它任务的压缩后的待打印日志。The second storage space component stores the compressed logs to be printed of the other tasks in a circular storage manner.
具体地,在本实施方式中,在进行存储新的待打印日志时,为了避免存储空间浪费,存储空间组件可以采用循环存储的方式存储待打印日志,也即如果存储的位置到达了存储空间的尽头时,则下一个内容会存储于存储空间的开头。Specifically, in this embodiment, when storing a new log to be printed, in order to avoid wasting storage space, the storage space component can store the log to be printed in a cyclic storage manner, that is, if the storage location reaches the limit of the storage space At the end, the next content will be stored at the beginning of the storage space.
在一些实施方式中,所述方法还包括:In some embodiments, the method further includes:
设定打印任务的优先级低于所述其它任务的优先级。The priority of the print task is set lower than the priority of the other tasks.
具体地,在本步骤中,在存在打印任务和其它任务时,将打印任务的优先级设置为最低,这样,就保证了打印任务不会影响其它任务的正常执行。Specifically, in this step, when there are printing tasks and other tasks, the priority of the printing tasks is set to the lowest, thus ensuring that the printing tasks will not affect the normal execution of other tasks.
响应于在执行所述打印任务的过程中,需开始执行其它任务并通知有新的日志需要打印时,则中断当前的打印任务,存储新的待打印日志以及更新打印任务中的所述打印标识组件。In response to the process of executing the printing task, when other tasks need to be executed and a new log needs to be printed, the current printing task is interrupted, the new log to be printed is stored, and the printing identification in the printing task is updated. components.
具体地,在本步骤中,当打印任务没有完成,而其它任务就开始执行并通知有新的日志需要打印时,打印任务的接口函数会存储新的日志内容,并更新打印任务中的打印标识组件。Specifically, in this step, when the print task is not completed, and other tasks start to execute and notify that there is a new log to be printed, the interface function of the print task will store the new log content and update the print identifier in the print task. components.
本实施例的日志打印方法,除了设置组件以外,还对打印任务的优先级进行设定,优先确保其它任务的正常执行,只有在系统空闲时(没有正在执行的其它任务),才开始启动打印任务。从而可以进一步提高打印效率,并能避免系统出现异常。In the log printing method of this embodiment, in addition to setting components, the priority of printing tasks is also set to ensure the normal execution of other tasks, and printing is started only when the system is idle (no other tasks being executed). Task. Thereby, the printing efficiency can be further improved, and the abnormality of the system can be avoided.
在一些实施方式中,所述根据所述打印标识组件的指示对所述压缩前的待打印日志进行压缩,包括:In some embodiments, compressing the log to be printed before compression according to the instruction of the printing identification component includes:
根据所述打印标识组件的指示,判断所述待打印日志的总长度是否大于预设压缩阈值。响应于所述待打印日志的总长度大于所述压缩阈值,则分次压缩所述待打印日志。According to the instruction of the print identification component, it is determined whether the total length of the log to be printed is greater than a preset compression threshold. In response to the total length of the log to be printed is greater than the compression threshold, the log to be printed is compressed in stages.
具体地,在本步骤中,每次压缩的长度有最大值限制,比如128个字节,如果待压缩的日志长度大于128个字节,则需要分两次或多次进行压缩。Specifically, in this step, the length of each compression has a maximum limit, such as 128 bytes. If the length of the log to be compressed is greater than 128 bytes, it needs to be compressed in two or more times.
本实施例的日志打印方法,在压缩之前,先判断待压缩的日志长度是否大于压缩阈值,并在大于压缩阈值时采用分批次压缩,从而可以提高压缩速度和压缩效率,避免因日志长度过长且采用一次压缩导致的系统崩溃或异常问题发生。In the log printing method of this embodiment, before compressing, it is judged whether the length of the log to be compressed is greater than the compression threshold, and when it is greater than the compression threshold, batch compression is adopted, so that the compression speed and compression efficiency can be improved, and the excessive log length can be avoided. System crashes or abnormal problems occur due to long and one-time compression.
在一些实施方式中,所述压缩标识组件包括压缩完成标识和压缩进度标识。所述更新所述压缩标识组件的压缩进度信息,包括:根据待压缩总数和压缩完成数量,更新所述压缩进度标识;以及,在压缩完成时,将所述压缩完成标识设置为第一预设值,未完成时,将所述压缩完成标识设置为第二预设值。In some embodiments, the compression indicator component includes a compression completion indicator and a compression progress indicator. The updating the compression progress information of the compression identification component includes: updating the compression progress identification according to the total number to be compressed and the compression completion quantity; and, when the compression is completed, setting the compression completion identification as a first preset If not completed, the compression completion flag is set to a second preset value.
具体地,在本步骤中,压缩是否完成用0或1来表示,1表示完成,0表示未完成。压缩进度用2个数字表示,分别是待压缩的总数,和已经完成的数目,比如待压缩总数是5,已完成是2,那么是否完成标志就是0,如果待压缩总数是5,已完成是5,那么是否完成标志就是1。Specifically, in this step, whether the compression is completed is represented by 0 or 1, 1 represents completion, and 0 represents not completed. The compression progress is represented by 2 numbers, which are the total number to be compressed and the number that has been completed. For example, the total number to be compressed is 5, and the completed number is 2, then the completion flag is 0. If the total number to be compressed is 5, the completed number is 0. 5, then the completion flag is 1.
在一些实施方式中,在打印完成所有的待打印日志之后,所述方法还包括:In some embodiments, after printing all logs to be printed, the method further includes:
清除存储空间组件中存储的打印日志,并重新设置所述打印任务中的打印标识组件和压缩标识组件。The print log stored in the storage space component is cleared, and the print identification component and the compression identification component in the print task are reset.
具体地,在本步骤中,当打印任务完成了所有的日志打印后,其重新设置任务中保存的打印标识组件和压缩标识组件,以使后续其他任务的日志存放在合理的位置。Specifically, in this step, after the printing task completes all log printing, it resets the print identification component and the compression identification component saved in the task, so that the logs of other subsequent tasks are stored in a reasonable location.
在一些实施方式中,所述输出打印完成的日志内容,包括:In some implementations, the outputting of the log content after printing includes:
通过直接调用寄存器的读写函数,输出打印完成的日志内容。By directly calling the read and write functions of the register, output the log content after printing.
具体地,在本步骤中,直接调用寄存器读写函数来发送数据,所花时间少于调用库函数发送数据的时间,原因是库函数比较复杂,因此,打印任务最终输出日志时,不会调用标准的库函数,而是直接调用寄存器的读写函数,以提高打印的效率。Specifically, in this step, directly calling the register read/write function to send data takes less time than calling the library function to send data. The reason is that the library function is more complicated. Therefore, when the print task finally outputs the log, it will not be called. Standard library functions, but directly call the read and write functions of registers to improve the efficiency of printing.
本公开的另一方面,如图3所示,提供一种日志打印装置300,该装置300可以适用于前文记载的方法,具体可以参考前文相关记载,在此不作赘述。所述装置300包括:Another aspect of the present disclosure, as shown in FIG. 3 , provides a log printing apparatus 300 . The apparatus 300 can be applied to the method described above. For details, reference may be made to the above-mentioned relevant records, which will not be repeated here. The apparatus 300 includes:
建立模块310,用于建立打印任务,所述打印任务包括打印标识组件和压缩标识组件;其中,所述打印标识组件用于指示压缩前的待打印日志的总长度、打印开始位置以及打印结束位置,所述压缩标识组件用于指示压缩进度信息;The establishment module 310 is used to establish a printing task, and the printing task includes a printing identification component and a compression identification component; wherein, the printing identification component is used to indicate the total length of the log to be printed before the compression, the printing start position and the printing end position , the compression identification component is used to indicate compression progress information;
压缩模块320,用于响应于其它任务有需要打印的日志,通过调用所述打印任务的接口函数通知所述打印任务,根据所述打印标识组件的指示对所述压缩前的待打印日志进行压缩,并更新所述压缩标识组件的压缩进度信息;The compression module 320 is configured to notify the printing task by invoking the interface function of the printing task in response to the log that needs to be printed in other tasks, and compress the log to be printed before the compression according to the instruction of the printing identification component , and update the compression progress information of the compression identification component;
打印模块330,用于响应于所述压缩标识组件指示的压缩进度信息为压缩完成信息,对压缩后的待打印日志进行打印;The printing module 330 is configured to print the compressed log to be printed in response to the compression progress information indicated by the compression identification component being the compression completion information;
输出模块340,用于输出打印完成的日志内容。The output module 340 is used for outputting the log content after printing.
本实施例的日志打印装置,通过设置打印标识组件和压缩标识组件,将待打印日志进行有效规划,并且在待打印日志进行打印前,先对该待打印日志进行压缩,然后对压缩后的待打印日志进行打印,可以极大提高日志打印效率,减少日志打印消耗的时间,避免由于打印操作耗时长而导致的问题。In the log printing device of this embodiment, the log to be printed is effectively planned by setting the print identification component and the compression identification component, and before the log to be printed is printed, the log to be printed is first compressed, and then the compressed log to be printed is compressed. Printing logs for printing can greatly improve the efficiency of log printing, reduce the time consumed by log printing, and avoid problems caused by long printing operations.
在一些实施方式中,所述打印任务还包括第一存储空间组件和第二存储空间组件。所述第一存储空间组件用于存储其它任务的压缩前的待打印日志。所述第二存储空间组件用于存储其它任务的压缩后的待打印日志。In some embodiments, the print job further includes a first storage space component and a second storage space component. The first storage space component is used for storing logs to be printed before compression of other tasks. The second storage space component is used for storing compressed logs to be printed of other tasks.
在一些实施方式中,所述第一存储空间组件采用循环存储的方式存储所述其它任务的压缩前的待打印日志;所述第二存储空间组件采用循环存储的方式存储所述其它任务的压缩后的待打印日志。In some embodiments, the first storage space component stores the logs to be printed before compression of the other tasks in a circular storage manner; the second storage space component stores the compressed logs of the other tasks in a circular storage manner The log to be printed after.
在一些实施方式中,如图3所示,所述装置300还包括:In some embodiments, as shown in FIG. 3 , the apparatus 300 further includes:
设定模块350,用于设定打印任务的优先级低于所述其它任务的优先级;a setting module 350, configured to set the priority of the printing task to be lower than the priority of the other tasks;
所述打印模块330,还用于响应于在执行所述打印任务的过程中,需开始执行其它任务并通知有新的日志需要打印时,则中断当前的打印任务,存储新的待打印日志以及更新打印任务中的所述打印标识组件。The printing module 330 is further configured to interrupt the current printing task and store the new log to be printed and the new log to be printed in response to the need to start executing other tasks and notify that there is a new log to be printed in the process of executing the printing task. The print identification component in the print job is updated.
在一些实施方式中,如图3所示,所述压缩模块320具体还用于:In some embodiments, as shown in FIG. 3 , the compression module 320 is further configured to:
根据所述打印标识组件的指示,判断所述待打印日志的总长度是否大于预设压缩阈值;According to the instruction of the printing identification component, determine whether the total length of the log to be printed is greater than a preset compression threshold;
响应于所述待打印日志的总长度大于所述压缩阈值,则分次压缩所述待打印日志。In response to the total length of the log to be printed is greater than the compression threshold, the log to be printed is compressed in stages.
在一些实施方式中,所述压缩标识组件包括压缩完成标识和压缩进度标识。所述压缩模块320具体还用于:根据待压缩总数和压缩完成数量,更新所述压缩进度标识;以及,在压缩完成时,将所述压缩完成标识设置为第一预设值,未完成时,将所述压缩完成标识设置为第二预设值。In some embodiments, the compression indicator component includes a compression completion indicator and a compression progress indicator. The compression module 320 is further configured to: update the compression progress indicator according to the total number to be compressed and the compression completed quantity; and, when the compression is completed, set the compression completion indicator to a first preset value, and when the compression is not completed , and the compression completion flag is set to a second preset value.
在一些实施方式中,如图3所示,所述输出模块340具体还用于:通过直接调用寄存器的读写函数,输出打印完成的日志内容。In some embodiments, as shown in FIG. 3 , the output module 340 is further configured to: output the log content after printing by directly calling the read and write functions of the register.
本公开的另一个方面,提供一种电子设备,包括一个或多个处理器;存储单元,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行时,能使得所述一个或多个处理器实现根据前文记载的所述的方法。Another aspect of the present disclosure provides an electronic device including one or more processors; a storage unit for storing one or more programs, when the one or more programs are executed by the one or more processors When executed, the one or more processors can be caused to implement the method according to the foregoing description.
本公开的另一个方面,提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时能实现根据前文记载的所述的方法。Another aspect of the present disclosure provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the method according to the foregoing description can be implemented.
其中,计算机可读存储介质可以是任何包含或存储程序的有形介质,其可以是电、磁、光、电磁、红外线、半导体的系统、装置、设备,更具体的例子包括但不限于:具有一个或多个导线的相连、便携式计算机磁盘、硬盘、光纤、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件,或它们任意合适的组合。Wherein, the computer-readable storage medium can be any tangible medium that contains or stores a program, which can be an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device. More specific examples include, but are not limited to: having a or multiple wires connected, portable computer disks, hard disks, optical fibers, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), portable compact disk read only memory ( CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
其中,计算机可读存储介质也可以包括在基带中或作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码,其具体的例子包括但不限于电磁信号、光信号,或它们任意合适的组合。The computer-readable storage medium may also include data signals in baseband or as part of a carrier wave, carrying computer-readable program codes, specific examples of which include but are not limited to electromagnetic signals, optical signals, or any suitable The combination.
可以理解的是,以上实施方式仅仅是为了说明本公开的原理而采用的示例性实施方式,然而本公开并不局限于此。对于本领域内的普通技术人员而言,在不脱离本公开的精神和实质的情况下,可以做出各种变型和改进,这些变型和改进也视为本公开的保护范围。It should be understood that the above embodiments are merely exemplary embodiments adopted to illustrate the principles of the present disclosure, but the present disclosure is not limited thereto. For those skilled in the art, various modifications and improvements can be made without departing from the spirit and essence of the present disclosure, and these modifications and improvements are also regarded as the protection scope of the present disclosure.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210462109.1ACN114860175A (en) | 2022-04-28 | 2022-04-28 | Log printing method and device, electronic equipment and computer readable storage medium |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210462109.1ACN114860175A (en) | 2022-04-28 | 2022-04-28 | Log printing method and device, electronic equipment and computer readable storage medium |
| Publication Number | Publication Date |
|---|---|
| CN114860175Atrue CN114860175A (en) | 2022-08-05 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202210462109.1APendingCN114860175A (en) | 2022-04-28 | 2022-04-28 | Log printing method and device, electronic equipment and computer readable storage medium |
| Country | Link |
|---|---|
| CN (1) | CN114860175A (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPH03114855A (en)* | 1989-09-29 | 1991-05-16 | Teraoka Seiko Co Ltd | Printer |
| JPH03157795A (en)* | 1989-11-16 | 1991-07-05 | Tokyo Electric Co Ltd | Product sales data processing device |
| CN101414248A (en)* | 2007-10-15 | 2009-04-22 | 佳能株式会社 | Printing apparatus and job processing method |
| CN101842785A (en)* | 2007-10-31 | 2010-09-22 | 惠普发展公司,有限责任合伙企业 | Collaborative compression |
| CN102970158A (en)* | 2012-11-05 | 2013-03-13 | 广东睿江科技有限公司 | Log storage and processing method and log server |
| US20140092437A1 (en)* | 2012-10-03 | 2014-04-03 | Brother Kogyo Kabushiki Kaisha | Printing apparatus and log recording method |
| CN105245753A (en)* | 2015-10-21 | 2016-01-13 | 天脉聚源(北京)教育科技有限公司 | Image processing method and device |
| CN107977442A (en)* | 2017-12-08 | 2018-05-01 | 北京希嘉创智教育科技有限公司 | Journal file compresses and decompression method, electronic equipment and readable storage medium storing program for executing |
| CN112130782A (en)* | 2020-09-22 | 2020-12-25 | 上海汉图科技有限公司 | A printing method, device and printing client |
| CN113467980A (en)* | 2020-03-30 | 2021-10-01 | 西安诺瓦星云科技股份有限公司 | Log output method, device and system and embedded equipment |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPH03114855A (en)* | 1989-09-29 | 1991-05-16 | Teraoka Seiko Co Ltd | Printer |
| JPH03157795A (en)* | 1989-11-16 | 1991-07-05 | Tokyo Electric Co Ltd | Product sales data processing device |
| CN101414248A (en)* | 2007-10-15 | 2009-04-22 | 佳能株式会社 | Printing apparatus and job processing method |
| CN101842785A (en)* | 2007-10-31 | 2010-09-22 | 惠普发展公司,有限责任合伙企业 | Collaborative compression |
| US20140092437A1 (en)* | 2012-10-03 | 2014-04-03 | Brother Kogyo Kabushiki Kaisha | Printing apparatus and log recording method |
| CN102970158A (en)* | 2012-11-05 | 2013-03-13 | 广东睿江科技有限公司 | Log storage and processing method and log server |
| CN105245753A (en)* | 2015-10-21 | 2016-01-13 | 天脉聚源(北京)教育科技有限公司 | Image processing method and device |
| CN107977442A (en)* | 2017-12-08 | 2018-05-01 | 北京希嘉创智教育科技有限公司 | Journal file compresses and decompression method, electronic equipment and readable storage medium storing program for executing |
| CN113467980A (en)* | 2020-03-30 | 2021-10-01 | 西安诺瓦星云科技股份有限公司 | Log output method, device and system and embedded equipment |
| CN112130782A (en)* | 2020-09-22 | 2020-12-25 | 上海汉图科技有限公司 | A printing method, device and printing client |
| Publication | Publication Date | Title |
|---|---|---|
| CN103412769B (en) | External card parameter configuration, equipment and system | |
| JP4960364B2 (en) | Hardware-assisted device configuration detection | |
| CN107977233A (en) | The quick loading method of kernel mirror image file and device | |
| CN108052407A (en) | A kind of application crash means of defence, device, equipment and storage medium | |
| CN115658185B (en) | Method, device, storage medium and electronic device for quick start of cloud application | |
| WO2023185335A1 (en) | Crash clustering method and apparatus, electronic device and storage medium | |
| CN113900743B (en) | A method and device for accessing Java objects | |
| CN110399168A (en) | System startup method, device and equipment for multi-data disk storage server | |
| CN112540880B (en) | A method, device and electronic device for quickly shielding faulty graphics cards in a cluster | |
| CN114860175A (en) | Log printing method and device, electronic equipment and computer readable storage medium | |
| CN111261206A (en) | Read-write method and device, electronic equipment and readable storage medium | |
| CN111625350A (en) | Memory allocation method, device, equipment and storage medium for network message data | |
| CN113396391B (en) | Application startup method, device, electronic device and storage medium | |
| CN111858665A (en) | A method, system, terminal and storage medium for improving soft copy read performance | |
| CN115658184B (en) | Method and device for quickly starting cloud application, storage medium and electronic equipment | |
| CN115656788B (en) | A chip test system, method, equipment and storage medium | |
| CN114706542A (en) | Log printing method and device, electronic equipment and computer readable storage medium | |
| CN114691549A (en) | A file writing method, device and computing device | |
| CN114661511B (en) | Device error processing method, device, equipment and storage medium | |
| CN112100622A (en) | Data processing method and equipment | |
| CN119515387A (en) | Blockchain transaction processing method, device, electronic device and storage medium | |
| CN109918122B (en) | White list maintenance method and device and terminal equipment | |
| CN118708250A (en) | Program startup method, device, electronic device and storage medium | |
| CN108345789B (en) | Method and device for recording memory fetch operation information | |
| CN117827114A (en) | Task processing method, device, equipment and computer readable storage medium |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| AD01 | Patent right deemed abandoned | Effective date of abandoning:20250829 |