Log recording method and device, electronic equipment and storage medium
By first writing the logs into the preset storage area in the electronic device, and then writing to the log files when a certain capacity is reached, the log invalidity problem caused by untimely user feedback is solved, and the effect of long-term logging and resource saving is achieved.
Patent Information
- Application Number
- CN202311531611.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-16
- Publication Date
- 2025-05-16
AI Technical Summary
In the prior art, user feedback is not timely, resulting in invalid logs, and R&D personnel are unable to analyze the causes of the problem, which affects the user experience.
Provides a logging method, first writes the log to the preset storage area, and when the log capacity reaches a certain amount, it is written to the log file and saved in an electronic device.
It realizes logging for a long time in electronic devices, avoids invalid log problems caused by untimely user feedback, improves user feedback experience, and saves write resources.
Smart Images

Figure CN120011330A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a log recording method, device, electronic device and storage medium. Background Art
[0002] Logs can reflect the operation of the system or application. When a user encounters a problem with an electronic device, the user can capture the log through the log capture function and record it in the electronic device, and at the same time feedback the captured log to the R&D personnel. The R&D personnel can analyze and solve the problem by viewing the log recorded in the electronic device to improve the user experience. However, in most cases, due to the untimely feedback from users, the logs cannot be captured within the limited time when the problem occurs, resulting in the feedback logs being invalid logs, so the R&D personnel cannot analyze the problem based on the feedback logs. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides a log recording method, device, electronic device and storage medium.
[0004] According to a first aspect of an embodiment of the present disclosure, a log recording method is provided, the method comprising:
[0005] Write logs to the preset storage area;
[0006] Whenever the log capacity in the preset storage area is greater than a first set value, writing the log in the preset storage area into a log file;
[0007] The log file is stored in an electronic device.
[0008] In an exemplary embodiment, a plurality of applications in the electronic device correspond to the same preset storage area;
[0009] The step of writing the log into a preset storage area includes:
[0010] Obtaining a first write address of the preset storage area;
[0011] synchronizing the first write address among the plurality of applications;
[0012] The log of each of the plurality of application programs is written into the preset storage area according to the first writing address.
[0013] In an exemplary embodiment, one application in the electronic device corresponds to one of the preset storage areas;
[0014] The step of writing the log into a preset storage area includes:
[0015] Obtaining a second write address of the preset storage area corresponding to the current application;
[0016] The log of the current application is written into the preset storage area according to the second writing address.
[0017] In an exemplary embodiment, writing the log in the preset storage area into a log file includes:
[0018] Creating the log file and determining the creation time of the log file;
[0019] The log file is opened, and the log in the preset storage area is written into the log file.
[0020] In an exemplary embodiment, the method further comprises:
[0021] When the log capacity in the log file is equal to the log capacity in the preset storage area, the write address of the preset storage area is set as the initial write address, and the log file is closed.
[0022] In an exemplary embodiment, the method further comprises:
[0023] When the number of the log files is greater than a second set value, the plurality of log files are arranged in order of their creation time, and the log file with the earliest creation time is deleted.
[0024] In an exemplary embodiment, the method further comprises:
[0025] When at least one of the following conditions is met, the error information is stored in the electronic device:
[0026] Before the log in the preset storage area is written into the log file, the log file fails to be opened;
[0027] After the logs in the preset storage area are written into the log file, the log capacity in the log file is not equal to the log capacity in the preset storage area;
[0028] When determining the number of the log files, the query path of the log files is wrong.
[0029] In an exemplary embodiment, the preset storage area is a buffer area.
[0030] In an exemplary embodiment, the log is an error log.
[0031] According to a second aspect of an embodiment of the present disclosure, a log recording device is provided, the device comprising:
[0032] A first writing module is configured to write the log into a preset storage area;
[0033] A second writing module is configured to write the logs in the preset storage area into a log file whenever the log capacity in the preset storage area is greater than a first set value;
[0034] The saving module is configured to save the log file in the electronic device.
[0035] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0036] processor;
[0037] a memory for storing processor-executable instructions;
[0038] The processor is configured to execute the method as described in the first aspect of the embodiment of the present disclosure.
[0039] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method described in the first aspect of the embodiment of the present disclosure.
[0040] The above method disclosed in the present invention has the following beneficial effects: it is possible to record logs for a long time in an electronic device, thereby avoiding the problem that R&D personnel cannot obtain effective logs due to untimely user feedback, improving the user's problem feedback experience, and first writing the log to a preset storage area, and then writing the log file when the log capacity in the preset storage area reaches a certain amount, which can avoid frequent opening and closing of files and save writing resources.
[0041] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0043] Figure 1 is a flow chart showing a log recording method according to an exemplary embodiment;
[0044] Figure 2 is a flow chart showing a log recording method according to an exemplary embodiment;
[0045] Figure 3 is a flow chart showing a log recording method according to an exemplary embodiment;
[0046] Figure 4 is a flow chart showing a log recording method according to an exemplary embodiment;
[0047] Figure 5 is a block diagram showing a log recording method according to an exemplary embodiment;
[0048] Figure 6 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0049] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0050] In the related art, log recording tools such as logcat or bugreport are used to capture and record logs. However, logcat is a lightweight log recording tool with a relatively short log capture time, while bugreport is a comprehensive system log recording tool that can record various information in the system, including various logs such as system operation logs and application operation logs. When the log capture time is long, the logs captured earlier will be overwritten by the logs captured later, resulting in invalid captured logs. Therefore, both tools can only capture and save logs within a limited time, but cannot capture long-term logs. If the user does not feedback the log within the limited time when the problem occurs, the effective log cannot be fed back, and the user cannot reproduce the problem, resulting in the inability of R&D personnel to analyze the cause of the problem and provide a solution, which seriously affects the user's experience.
[0051] In an exemplary embodiment of the present disclosure, in order to overcome the problem of invalid feedback caused by untimely feedback in the related art, a log recording method is provided, including: writing logs into a preset storage area; whenever the log capacity in the preset storage area is greater than a first set value, writing the logs in the preset storage area into a log file; and saving the log file in an electronic device. This method can record logs for a long time in an electronic device, avoid the problem that R&D personnel cannot obtain valid logs due to untimely user feedback, and improve the user's problem feedback experience. In addition, the logs are first written into the preset storage area, and then the log file is written when the log capacity in the preset storage area reaches a certain amount, which can avoid frequent opening and closing of files and save writing resources.
[0052] In an exemplary embodiment of the present disclosure, a log recording method is provided. Figure 1 is a flow chart of a log recording method according to an exemplary embodiment. Figure 1 As shown, the following steps are included:
[0053] Step S101, writing the log into a preset storage area;
[0054] Step S102, whenever the log capacity in the preset storage area is greater than a first set value, the log in the preset storage area is written into a log file;
[0055] Step S103, saving the log file in the electronic device.
[0056] The log recording method in the exemplary embodiment of the present disclosure is applied to electronic devices, including smart phones, tablet computers, personal computers, smart wearable devices, smart home devices, smart car systems and other electronic devices with processors and memories. The method in this embodiment is used as the default log recording method in the electronic device.
[0057] In step S101, the preset storage area is a temporary storage area, which can be used to quickly store logs. The processor captures the logs in real time and writes the logs into the preset storage area in real time. The preset storage area is different from the storage area of the log file. The storage area of the log file is in the memory of the electronic device, and the preset storage area is the storage area between the processor and the memory, for example, the preset storage area is a buffer area.
[0058] The logs captured by the processor include error logs, which represent the key parameters of the key links in the program captured when the program is abnormal. R&D personnel can track and locate the problem and analyze the cause of the abnormality based on the error log. The logs captured by the processor can also include other types of logs, such as load logs, behavior logs, etc.
[0059] In step S102, the log capacity in the preset storage area is counted in real time. The log capacity represents the byte size of all the logs written. When the log capacity is greater than the first set value, the logs in the preset storage area are written into the log file, and the latest captured logs are rewritten into the preset storage area, and the log capacity in the preset storage area is counted in real time. Whenever the log capacity of the preset storage area is greater than the first set value, the operation of writing the logs in the preset storage area into the log file is performed once, and the operation is repeated. The first set value is an empirical value, which is set according to demand. For example, the first set value is set with the byte size of all the logs that can be captured within an hour as a reference value.
[0060] When writing logs in a preset storage area to a log file, the logs in the preset storage area may be written to a log file each time, or the logs in multiple preset storage areas may be written to the same log file. The log file may be created each time the logs in the preset storage area need to be written, or it may be created in advance and used when the logs in the preset storage area need to be written.
[0061] After capturing the log, the processor writes the log to the preset storage area first, and then writes the log file when the log capacity in the preset storage area reaches a certain amount, instead of writing the captured log to the log file in real time. This can avoid frequent opening and closing of files and save writing resources.
[0062] In step S103, each log file written into the log is saved in the electronic device, that is, the log file is stored in the memory of the electronic device, so that the log can be recorded in the electronic device for a longer period of time.
[0063] In some possible implementations, the log in this embodiment is an error log captured by the processor, that is, it does not include other types of logs. Since the amount of data in the error log is relatively small, only the error log is saved in the electronic device, which not only ensures that the R&D personnel can locate the problem and analyze the cause according to the saved log file, but also saves the memory space of the electronic device. In addition, if the behavior log is not recorded when recording the log, the specific operation of the user will not be recorded, which can avoid privacy issues.
[0064] In an exemplary embodiment of the present disclosure, logs are continuously captured and written to a preset storage area. Whenever the log capacity in the preset storage area is greater than a first set value, the logs in the preset storage area are written to a log file, and the log file is saved in the electronic device. This allows the electronic device to record logs for a longer period of time, thereby avoiding the problem of R&D personnel being unable to obtain valid logs due to untimely user feedback, thereby improving the user's problem feedback experience. In addition, the logs are first written to the preset storage area, and then the log file is written when the log capacity in the preset storage area reaches a certain amount, thereby avoiding frequent opening and closing of files and saving writing resources.
[0065] In an exemplary embodiment of the present disclosure, a log recording method is provided. Figure 2 is a flow chart of a log recording method according to an exemplary embodiment. Figure 2 As shown, the following steps are included:
[0066] Step S201, determining the correspondence between the preset storage area and the application program;
[0067] If multiple applications in the electronic device correspond to the same preset storage area, execute steps S202-S204; if one application in the electronic device corresponds to one preset storage area, execute steps S205-S206;
[0068] Step S202, obtaining a first write address of a preset storage area;
[0069] Step S203, synchronizing the first write address in multiple applications;
[0070] Step S204, writing the log of each application program among the plurality of application programs into a preset storage area according to the first writing address;
[0071] Step S205, obtaining a second write address of a preset storage area corresponding to the current application;
[0072] Step S206, writing the log of the current application into a preset storage area according to the second write address;
[0073] Step S207, whenever the log capacity in the preset storage area is greater than a first set value, the logs in the preset storage area are written into the log file;
[0074] Step S208: save the log file in the electronic device.
[0075] The specific implementation of steps S207-S208 refers to steps S102-S103, which will not be repeated here.
[0076] In step S201, when writing logs in the preset storage area, all logs in the system can be written into the same preset storage area, or the logs of an application can be written into a preset storage area, or some more important applications can be written into a preset storage area respectively, and the remaining multiple applications can be written into the same preset storage area.
[0077] In steps S202-S204, when multiple applications correspond to the same preset storage area, the first write address in the preset storage area is obtained, and the first write address is synchronized to each of the multiple applications to ensure that the log of each application does not overwrite the previous log when writing. The first write address is used to indicate the write position of the log in the preset storage area. For example, the first write address can be assigned to the variable buf_pos, and each of the multiple applications calls the variable to write the log in the first write address. When a certain application finishes writing, the first write address is updated, that is, the value of the variable is updated, and other applications automatically substitute the updated value when calling the variable.
[0078] If multiple applications share one preset storage area, there is no need to set up multiple preset storage areas, which can save storage space in the buffer area.
[0079] In steps S205-S206, when an application corresponds to a preset storage area, each application obtains the second write address of the preset storage area corresponding to the current application in the preset storage area corresponding to the log, and writes the log of the current application into the corresponding preset storage area according to the second write address. The second write address is used to indicate the write position in the preset storage area corresponding to the current application. In order to distinguish the preset storage areas corresponding to different applications, the second write address includes not only the write position in the preset storage area, but also the identifier of the preset storage area, that is, which preset storage area is written. For example, the second write address can be assigned to variables buf and buf_pos, and the current application calls the two variables to write the log in the preset storage area corresponding to the variable buf and the write position corresponding to the variable buf_pos. After the writing is completed, the variable buf is kept unchanged, and the variable buf_pos is updated, that is, the write position is updated. Then, the next time the current application calls the variable, the updated write position is automatically substituted.
[0080] Setting a preset storage area for an application makes log files more organized. When analyzing problems later, R&D personnel can quickly locate the log file corresponding to the problem based on the application where the problem occurred.
[0081] It should be noted that in the above two cases, when the application contains multiple threads, it is also necessary to synchronize the write addresses between the multiple threads to avoid log overwriting.
[0082] In some possible implementations, some applications in the electronic device correspond to the same preset storage area, and some applications each correspond to a preset storage area. For example, a preset storage area is set separately for the core application, and the remaining applications share the same preset storage area. This can not only save storage space in the buffer area, but also help R&D personnel to quickly locate the log file corresponding to the problem based on the application with the problem.
[0083] In an exemplary embodiment of the present disclosure, a log recording method is provided. Figure 3 is a flow chart of a log recording method according to an exemplary embodiment. Figure 3 As shown, the following steps are included:
[0084] Step S301, writing the log into a preset storage area;
[0085] Step S302, whenever the log capacity in the preset storage area is greater than a first set value, a log file is created and the creation time of the log file is determined;
[0086] Step S303, opening the log file, and writing the log in the preset storage area into the log file;
[0087] Step S304, when the log capacity in the log file is equal to the log capacity in the preset storage area, the write address of the preset storage area is set as the initial write address, and the log file is closed;
[0088] Step S305, saving the log file in the electronic device;
[0089] Step S306: When the number of log files is greater than the second set value, the multiple log files are arranged in the order of the log file creation time, and the log file with the earliest creation time is deleted.
[0090] The specific implementation of step S301 refers to step S101 or steps S201-S206, which will not be repeated here.
[0091] In step S302, when the log of the preset storage area needs to be written into the log file, that is, whenever the log capacity in the preset storage area is greater than the first set value, a log file is created under the preset path, and the creation time of the log file is determined. The creation time is based on the system time, and the creation time can be accurate to hours or minutes. The creation time is recorded in the log file, or the log file is named according to the creation time for subsequent viewing.
[0092] Creating a log file when the logs in the preset storage area need to be written to the log file, rather than creating the log file in advance, can avoid overwriting the log due to incorrect file selection during writing, and facilitate the subsequent determination of the number of log files that have been written to the log. In addition, recording the creation time of the log file facilitates the subsequent distinction between multiple log files.
[0093] In steps S303-S304, after the creation is completed, the log file is opened, and the log in the preset storage area is written into the log file. When the log capacity in the log file is equal to the log capacity in the preset storage area, it indicates that the writing is successful. If the log capacity in the log file is not equal to the log capacity in the preset storage area, it indicates that the writing fails. After the log in the preset storage area is successfully written into the log file, the preset storage area is reset, that is, the write address of the preset storage area is set to the initial write address, so that the latest captured log is rewritten at the initial position, so that the newly captured log covers the log that has been written into the log file, and there is no need to delete the log in the preset storage area. In addition, when the log in the preset storage area is successfully written into the log file, the log file is closed in time to avoid resource leakage.
[0094] It should be noted that when logs of multiple preset storage areas are written to the same log file, a log file is created when the log capacity of the first preset storage area is greater than the first set value. There is no need to create the log file again subsequently, and the last log file can be directly opened and written.
[0095] In steps S305-S306, the log file is saved in a preset path in the electronic device, and the number of log files in the preset path is counted. When the number of log files is greater than the second set value, multiple log files are arranged in the order of the log file creation time, and the arrangement results are input into the array, and the log file with the earliest creation time is deleted. Among them, the second set value is an empirical value, which is set according to actual needs. For example, if you want to record logs within 72 hours in the electronic device, if the log file is created and written in units of one hour, the second set value is 72; if the log file is created and written in units of two hours, the second set value is 36. Deleting log files with earlier creation times can ensure that the latest log files are retained in the electronic device and save memory space.
[0096] It should be noted that the log file creation time in this embodiment is the writing time of the log file into the log. In some possible implementations, when the number of log files is greater than the second set value, multiple log files are arranged in the order of the writing time of the log files into the log, and the log file with the earliest writing time is deleted.
[0097] In an exemplary embodiment of the present disclosure, a log recording method is provided. Figure 4 is a flow chart of a log recording method according to an exemplary embodiment. Figure 4 As shown, the following steps are included:
[0098] Step S401, writing the log into a preset storage area;
[0099] Step S402, determining the log capacity in the preset storage area;
[0100] If the log capacity in the preset storage area is less than or equal to the first set value, continue to write the log into the preset storage area; if the log capacity in the preset storage area is greater than the first set value, execute step S403;
[0101] Step S403, creating a log file in a preset path and determining the creation time of the log file;
[0102] Step S404, opening the log file;
[0103] If the log file fails to be opened, the error information is recorded and saved in the electronic device; if the log file is successfully opened, step S405 is executed;
[0104] Step S405, writing the logs in the preset storage area into a log file;
[0105] Step S406, determining whether the log capacity in the log file is equal to the log capacity in the preset storage area;
[0106] If the log capacity in the log file is not equal to the log capacity in the preset storage area, an error message is recorded and the error message is stored in the electronic device; if the log capacity in the log file is equal to the log capacity in the preset storage area, step S407 is executed;
[0107] Step S407, setting the write address of the preset storage area as the initial write address, and closing the log file;
[0108] Step S408, saving the log file in the electronic device;
[0109] Step S409, traverse the log files under the preset path;
[0110] If the preset path does not exist or the preset path is not the directory of the log file, record the error information and save the error information in the electronic device; if the preset path is the directory of the log file, execute step S410;
[0111] Step S410, determining the number of log files;
[0112] If the number of log files is less than or equal to the second set value, continue to save the log files in the electronic device; if the number of log files is greater than the second set value, execute step S411;
[0113] Step S411, arranging multiple log files in the order of their creation time, and deleting the log file with the earliest creation time.
[0114] In this embodiment, by determining whether the execution conditions for subsequent execution are met and recording error information if they are not met, problems caused by the interaction between the current log recording method and other functions in the electronic device can be avoided, thereby ensuring the robustness and stability of the log recording function.
[0115] In an exemplary embodiment of the present disclosure, a log recording device is provided. Figure 5 is a block diagram of a log recording device according to an exemplary embodiment. Figure 5 As shown, the logging device comprises:
[0116] The first writing module 501 is configured to write the log into a preset storage area;
[0117] The second writing module 502 is configured to write the logs in the preset storage area into the log file whenever the log capacity in the preset storage area is greater than the first set value;
[0118] The saving module 503 is configured to save the log file in the electronic device.
[0119] In an exemplary embodiment, multiple applications in the electronic device correspond to the same preset storage area;
[0120] The first writing module 501 is further configured as follows:
[0121] Obtaining a first write address of a preset storage area;
[0122] synchronizing a first write address among multiple applications;
[0123] The log of each application program among the plurality of application programs is written into a preset storage area according to the first writing address.
[0124] In an exemplary embodiment, an application in the electronic device corresponds to a preset storage area;
[0125] The first writing module 501 is further configured as follows:
[0126] Obtaining a second write address of a preset storage area corresponding to the current application;
[0127] According to the second write address, the log of the current application is written into the preset storage area.
[0128] In an exemplary embodiment, the second writing module 502 is further configured to:
[0129] Create a log file and determine the time when the log file was created;
[0130] Open the log file and write the logs in the preset storage area into the log file.
[0131] In an exemplary embodiment, the second writing module 502 is further configured to:
[0132] When the log capacity in the log file is equal to the log capacity in the preset storage area, the write address of the preset storage area is set as the initial write address, and the log file is closed.
[0133] In an exemplary embodiment, the saving module 503 is further configured to:
[0134] When the number of log files is greater than the second set value, the multiple log files are arranged in the order of the log file creation time, and the log file with the earliest creation time is deleted.
[0135] In an exemplary embodiment, the second writing module 502 is further configured to:
[0136] When at least one of the following conditions is met, the error information is stored in the electronic device:
[0137] The log file fails to open before the logs in the preset storage area are written to the log file;
[0138] After the logs in the preset storage area are written into the log file, the log capacity in the log file is not equal to the log capacity in the preset storage area.
[0139] In an exemplary embodiment, the saving module 503 is further configured to:
[0140] When determining the number of log files, the query path of the log files is wrong, and the error information is stored in the electronic device.
[0141] In an exemplary embodiment, the preset storage area is a buffer area.
[0142] In an exemplary embodiment, the log is an error log.
[0143] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0144] Figure 6 is a block diagram of an electronic device 600 according to an exemplary embodiment.
[0145] Reference Figure 6 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .
[0146] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
[0147] The memory 604 is configured to store various types of data to support operations on the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0148] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.
[0149] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0150] The audio component 610 is configured to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.
[0151] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0152] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of the components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of contact between the user and the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0153] The communication component 616 is configured to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0154] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0155] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the instructions can be executed by a processor 620 of an electronic device 600 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0156] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform a logging method, the method including any of the above methods.
[0157] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0158] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A log recording method, characterized in that: The method comprises: Write logs to the preset storage area; Whenever the log capacity in the preset storage area is greater than a first set value, writing the log in the preset storage area into a log file; The log file is stored in an electronic device.
2. The method according to claim 1, characterized in that The multiple applications in the electronic device correspond to the same preset storage area; The step of writing the log into a preset storage area includes: Obtaining a first write address of the preset storage area; synchronizing the first write address among the plurality of applications; The log of each of the plurality of application programs is written into the preset storage area according to the first writing address.
3. The method according to claim 1, characterized in that One application in the electronic device corresponds to one of the preset storage areas; The step of writing the log into a preset storage area includes: Obtaining a second write address of the preset storage area corresponding to the current application; The log of the current application is written into the preset storage area according to the second writing address.
4. The method according to claim 1, characterized in that: The step of writing the log in the preset storage area into a log file includes: Creating the log file and determining the creation time of the log file; The log file is opened, and the log in the preset storage area is written into the log file.
5. The method according to claim 4, characterized in that The method further comprises: When the log capacity in the log file is equal to the log capacity in the preset storage area, the write address of the preset storage area is set as the initial write address, and the log file is closed.
6. The method according to claim 4, characterized in that The method further comprises: When the number of the log files is greater than a second set value, the plurality of log files are arranged in order of their creation time, and the log file with the earliest creation time is deleted.
7. The method according to claim 1, characterized in that The method further comprises: When at least one of the following conditions is met, the error information is stored in the electronic device: Before the log in the preset storage area is written into the log file, the log file fails to be opened; After the logs in the preset storage area are written into the log file, the log capacity in the log file is not equal to the log capacity in the preset storage area; When determining the number of the log files, the query path of the log files is wrong.
8. The method according to any one of claims 1 to 7, characterized in that: The preset storage area is a buffer area.
9. The method according to any one of claims 1 to 7, characterized in that: The log is an error log.
10. A log recording device, characterized in that: The device comprises: A first writing module is configured to write the log into a preset storage area; A second writing module is configured to write the logs in the preset storage area into a log file whenever the log capacity in the preset storage area is greater than a first set value; The saving module is configured to save the log file in the electronic device.
11. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method as claimed in any one of claims 1 to 9.
12. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as claimed in any one of claims 1 to 9.