Log recording method, log acquisition method, electronic device, and readable storage medium

CN123011661APending Publication Date: 2026-10-30ZHEJIANG HUARAY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611160117.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-31
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

这种方式记录的日志时间不够准确

Benefits of technology

[0015]上述方案,通过响应于接收到上位机发送的时间信息,根据时间信息确定相机端的当前记录时间;基于当前记录时间记录日志,得到当前日志,当前日志包括上位机的当前时间戳;将当前日志存储至缓存区。由此,基于上位机的时间信息来确定相机端的当前记录时间,进而得到包含上位机当前时间戳的当前日志,保证了当前日志与上位机之间的时间一致,从而提高了日志记录时间的准确性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123011661A_ABST
    Figure CN123011661A_ABST
Patent Text Reader

Abstract

The application discloses a log recording method, a log acquisition method, an electronic device and a readable storage medium. According to the application, in response to receiving time information sent by a host computer, a current recording time of a camera end is determined according to the time information; a current log is obtained by recording a log based on the current recording time, the current log including a current time stamp of the host computer; and the current log is stored in a cache area. Therefore, the accuracy of the log recording time is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a log recording method, a log acquisition method, an electronic device, and a readable storage medium. Background Technology

[0002] Industrial cameras are core image acquisition devices in fields such as intelligent manufacturing, machine vision, industrial inspection, and automated production lines, and typically need to operate stably for extended periods in industrial environments. Industrial cameras and various embedded vision devices commonly employ local log storage technology to persistently store equipment operation logs and other data in a storage area, enabling post-event tracking of equipment operating status, fault location, and performance analysis.

[0003] Existing logging methods typically rely on the system's soft clock for industrial cameras to record logs. However, the time recorded in this way is not accurate enough. Summary of the Invention

[0004] The main technical problem addressed by this application is to provide a log recording method, a log acquisition method, an electronic device, and a readable storage medium that can improve the accuracy of log recording time.

[0005] To address the aforementioned technical problems, this application provides a log recording method applied to a camera, the camera including a buffer, the camera being communicatively connected to a host computer, the method comprising: responding to receiving time information sent by the host computer, determining the current recording time of the camera based on the time information; recording a log based on the current recording time to obtain a current log, the current log including the current timestamp of the host computer; and storing the current log in the buffer.

[0006] In one embodiment, the step of determining the current recording time of the camera based on the time information includes: performing time merging processing on the time information to obtain the current timestamp of the host computer; and determining the current recording time of the camera based on the current timestamp of the host computer.

[0007] In one embodiment, the camera terminal includes an application layer and a driver layer, and the step of storing the current log in the cache includes: sending the current log to the driver layer through the macro interface of the application layer; and writing the current log into the cache through the driver layer.

[0008] In one embodiment, the cache includes a primary partition and a backup partition, and the step of writing the current log into the cache through the driver layer includes: determining the writing strategy for the current log; and writing the current log into the primary partition and the backup partition respectively according to the writing strategy.

[0009] In one embodiment, the camera includes a switch register, and the step of writing the current log to the buffer through the driver layer includes: writing the current log to the buffer in response to detecting that the switch register is in an on state; and stopping writing the current log in response to detecting that the switch register is in a off state.

[0010] In one embodiment, the cache includes a primary partition and a backup partition. After the step of storing the current log in the cache, the method further includes: in response to receiving a log recovery instruction, determining a target log from the backup partition based on the log to be recovered in the log recovery instruction; and writing the target log into the primary partition.

[0011] To address the aforementioned technical problems, this application provides a log acquisition method applied to a host computer. The method includes: in response to detecting a connection between the host computer and a camera, determining whether the camera has a logging function; if so, splitting the current timestamp of the host computer to obtain time information; sending the time information to the camera and triggering the camera to respond to receiving the time information sent by the host computer, determining the current recording time of the camera based on the time information; recording a log based on the current recording time to obtain a current log, the current log including the current timestamp of the host computer; and storing the current log in the cache.

[0012] In one embodiment, after the step of sending the time information to the camera, the method further includes: in response to receiving a log read instruction, obtaining log information from the main partition of the camera; verifying the log information to obtain a verification result; in response to the verification result indicating a verification failure, obtaining log information from the backup partition of the camera and sending a log recovery instruction for the main partition to the camera.

[0013] To address the aforementioned technical problems, this application provides an electronic device, including a memory and a processor. The memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the aforementioned log recording method and log acquisition method.

[0014] To address the aforementioned technical problems, this application provides a computer-readable storage medium, comprising: storing program data, wherein the program data, when executed by a processor, is used to implement the aforementioned log recording method and log acquisition method.

[0015] The above scheme, in response to receiving time information from the host computer, determines the current recording time of the camera based on the time information; records a log based on the current recording time, obtaining the current log, which includes the current timestamp from the host computer; and stores the current log in a buffer. Thus, by determining the current recording time of the camera based on the host computer's time information, and thereby obtaining the current log containing the host computer's current timestamp, the time consistency between the current log and the host computer is ensured, thereby improving the accuracy of the log recording time. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly described below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein: Figure 1 This is a flowchart illustrating an exemplary embodiment of the logging method shown in this application; Figure 2 This is a schematic diagram of an exemplary embodiment of the camera terminal and the host computer shown in this application; Figure 3 This is a flowchart illustrating an exemplary embodiment of the log acquisition method shown in this application; Figure 4 This is a block diagram illustrating a log recording device in an exemplary embodiment of this application; Figure 5 This is a block diagram illustrating a log acquisition apparatus according to an exemplary embodiment of this application; Figure 6 This is a schematic diagram of the structure of an embodiment of the electronic device provided in this application; Figure 7 This is a schematic diagram of an embodiment of the computer-readable storage medium provided in this application. Detailed Implementation

[0017] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It is understood that the specific embodiments described herein are only for explaining this application and not for limiting it. Furthermore, it should be noted that, for ease of description, only the parts related to this application are shown in the accompanying drawings, not all structures. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0018] First, it's important to note that industrial cameras are core image acquisition devices in fields such as intelligent manufacturing, machine vision, industrial inspection, and automated production lines, and typically need to operate stably for extended periods in industrial environments. Industrial cameras and various embedded vision devices commonly employ local log storage technology to persistently store equipment operation logs and other data in a storage area, enabling post-event tracking of equipment operating status, fault location, and performance analysis. Existing logging methods usually rely on the industrial camera's system soft clock for recording logs. This method results in insufficiently accurate log timestamps.

[0019] Because fault scenarios are inherently unreproducible, traditional debugging methods such as log printing and real-time serial port capture are not only inefficient but also prone to missing critical operational status data. This leads to long troubleshooting cycles and significant difficulty in fault location, severely impacting the continuity and stability of industrial production. Existing industrial cameras and various embedded vision devices commonly employ local log storage technology to persistently store equipment operation logs, fault alarm information, configuration interaction records, and image acquisition status data to Flash memory, SD (Secure Digital) cards, or other non-volatile storage media, enabling post-event traceability of equipment operation status, fault location, and performance analysis. However, in low-cost, hardware-restricted industrial camera scenarios, most devices lack dedicated RTC (Real-Time Clock) hardware chips. Furthermore, existing log recording methods suffer from numerous technical bottlenecks in areas such as high-frequency writing, power-off anomalies, export management, and cross-platform compatibility. These limitations fail to meet the high reliability, high stability, and scalability requirements of industrial applications, hindering the efficient operation of industrial camera log systems.

[0020] Based on this, this application provides a logging method. For details, please refer to [link / reference needed]. Figure 1 , Figure 1 This is a flowchart illustrating an exemplary embodiment of a logging method shown in this application.

[0021] The executing entity of a logging method can be a terminal device, a server, or other processing device. The terminal device can be a computer, mobile device, terminal, computing device, vehicle-mounted device, etc. The executing entity of a logging method can also be a logging device. In some possible implementations, the logging method can be implemented by a processor calling computer-readable instructions stored in memory. The executing entity of a logging method can also be a big data cluster. A big data cluster is a computer system architecture formed by multiple computers connected through a network. Big data clusters can be deployed on a private cloud built with Kubernetes (a container orchestration engine).

[0022] Specifically, the logging method is applied to the camera, which includes a buffer and a communication connection with the host computer.

[0023] The camera can be an industrial camera. For example... Figure 2 As shown, the host computer can be a PC (Personal Computer), which includes a client and an SDK (Software Development Kit). The industrial camera includes an application layer, a driver layer, and a buffer. The buffer includes a primary Flash partition and a secondary Flash partition. The application layer communicates with the driver layer, and the driver layer connects to both the primary and secondary Flash partitions.

[0024] One log recording method in this embodiment includes the following steps: S110. In response to receiving time information sent by the host computer, determine the current recording time of the camera based on the time information.

[0025] Time information refers to information that represents the current timestamp. For example, time information includes 32 bits of low-order time data and 32 bits of high-order time data, which are obtained by splitting the 64-bit current timestamp from the host computer.

[0026] The logging device responds to the time information received from the host computer and determines the current recording time at the camera based on the time information. As an example, the logging device merges the high-order and low-order time data into the host computer's current timestamp; the host computer's current timestamp is then used as the camera's current recording time.

[0027] As another example, the steps of the logging device to determine the current recording time of the camera based on time information include: performing time merging processing on the time information to obtain the current timestamp of the host computer; and determining the current recording time of the camera based on the current timestamp of the host computer.

[0028] The log recording device performs time merging processing on the time information to obtain the current timestamp of the host computer. Specifically, the log recording device places the high-order time data to the left of the low-order time data, and uses the combined high-order and low-order time data as the current timestamp of the host computer.

[0029] In one embodiment, the driver layer includes a high-order timestamp register and a low-order timestamp register. The host computer's SDK writes the high-order timestamp data to the high-order timestamp register and the low-order timestamp data to the low-order timestamp register. After the camera detects that the high-order timestamp register and the low-order timestamp register contain data, it uses the write callback function corresponding to the high-order timestamp register to retrieve the high-order timestamp data stored in the high-order timestamp register and the write callback function corresponding to the low-order timestamp register to retrieve the low-order timestamp data stored in the low-order timestamp register. Then, it shifts the high-order timestamp data left by 32 bits and combines it with the low-order timestamp data to obtain a 64-bit current timestamp. Finally, it calls the time base setting interface to set the current timestamp as the current recording time of the camera.

[0030] The logging device determines the current recording time of the camera based on the current timestamp of the host computer. Specifically, the logging device uses the current timestamp of the host computer as the absolute time reference, records the count value of the local crystal oscillator clock at the absolute time reference moment, and uses this count value as the reference count value; it acquires the current count value of the local crystal oscillator clock and the reference count value in real time, calculates the time difference between the current count value and the reference count value, and determines the sum of the absolute time reference and the time difference as the current recording time of the camera at each moment.

[0031] The absolute time base is the millisecond count value of the real time on the PC side, and the count value of the local crystal oscillator clock is generated by the free-running timer driven by the internal crystal oscillator of the camera, which represents the running time of the camera itself.

[0032] In one embodiment, after obtaining the current timestamp from the host computer, the logging device, in response to the camera not receiving new time information from the host computer, reads the current count value of the local crystal oscillator clock when recording the log, and calculates the time difference between the current count value and the reference count value. The calculation of the time difference is implemented by unsigned subtraction and conversion to a signed difference to avoid calculation errors caused by the 64-bit count value wrapping around. The logging device uses the sum of the time difference and the absolute time reference as the current recording time of the log. Thus, when the camera is disconnected from the host computer (i.e., offline), the SDK no longer updates the absolute time reference, but the camera's local crystal oscillator continues to run. The logging device still uses the camera's internal crystal oscillator clock as a continuous source of time increment in the above manner, keeping the log timestamp monotonically and stably increasing, thereby achieving stable generation and recording of the real timestamp in the offline state.

[0033] As can be seen, during the communication connection establishment phase between the host computer and the camera, the real-world timestamp is synchronously written into the camera's dedicated register. The driver layer on the camera reads the data from this register and sets it as the absolute time reference. Combined with the camera's internal crystal oscillator, time drift compensation is performed, thereby achieving stable generation and logging of the real timestamp in offline mode. This solves the technical pain points of inaccurate timestamps and inability to correlate with real-world time in scenarios without RTC (Real-Time Clock) hardware.

[0034] In another embodiment, the logging device, in response to the camera being in communication with the host computer, acquires the current timestamp sent by the host computer in real time; updates each acquired current timestamp to a new absolute time reference, and uses the count value of the local crystal oscillator clock at the time of the new absolute time reference as the new reference count value; and acquires a new current recording time based on the new absolute time reference and the new reference count value. Thus, whenever the SDK reconnects to the camera and sends time information again, the logging device re-anchors the host computer's absolute time reference and the local crystal oscillator's reference count value, thereby correcting the time drift accumulated during offline periods due to internal crystal oscillator frequency deviations, such as temperature drift and time drift, as well as any possible absolute time offset.

[0035] It can be seen that by providing continuous, monotonous, and offline incremental time through the internal crystal oscillator of the camera to ensure short-term stability, and by providing an absolute reference through periodic resynchronization of the host computer's precise clock to correct long-term accumulated drift, the combination of the two achieves stable generation and reliable recording of the system log's true timestamp in offline mode.

[0036] S120. Record the log based on the current recording time to obtain the current log, which includes the current timestamp of the host computer.

[0037] The current log refers to the event records during the camera's operation. For example, the current log may include various abnormal behaviors such as communication interruptions, configuration parameter errors, system kernel crashes, hardware interface failures, and image acquisition anomalies in industrial cameras.

[0038] The logging device records events at the camera at the current moment and combines the current recording time and events into the current log.

[0039] The current log data structure in the logging device uses a fixed-length, big-endian byte order, unaffected by CPU (Central Processing Unit) architecture. The logging device also provides a standard API (Application Programming Interface) and register mapping specifications, facilitating rapid adaptation to different camera models, improving cross-platform compatibility, and simplifying integration and parsing.

[0040] S130. Store the current log in the cache.

[0041] A buffer is an area where data can be stored. A buffer can be a Flash memory, a non-volatile storage chip that is erased in blocks and written to in pages. It has a fixed upper limit for erase / write cycles, such as approximately 100,000 cycles for SLC (Single-Level Cell) and approximately 10,000 cycles for MLC (Multi-Level Cell). High-frequency, small-volume writes will significantly shorten its lifespan.

[0042] As an example, the application layer of the logging device sends the current log to the driver layer through a macro interface. The driver layer caches the current log in a memory circular buffer and writes the log in the memory circular buffer to the cache area at preset time intervals.

[0043] As another example, the camera end includes an application layer and a driver layer. The step of the logging device storing the current log in the buffer includes: sending the current log to the driver layer through the macro interface of the application layer; and writing the current log into the buffer through the driver layer.

[0044] The buffer includes a primary partition and a backup partition. The steps for writing the current log to the buffer through the driver layer include: determining the writing strategy for the current log; and writing the current log to the primary partition and the backup partition respectively according to the writing strategy.

[0045] The current log write strategy can be either a periodic write strategy, which means writing the current log to the primary and secondary partitions at preset time intervals; an immediate write strategy, which means writing the current log directly to the primary and secondary partitions; or an interval write strategy, which means writing the current log to the primary partition and then synchronizing the logs with the primary and secondary partitions at preset time intervals.

[0046] In some embodiments, during the initialization phase, the camera initializes the logging device via DRV_slogInit (Driver Serial LogInitialize), checks the availability of the primary and backup Flash partitions, and starts a periodic disk flushing thread. The flushing cycle is 1 second. During the time synchronization phase, the camera detects a successful connection between the SDK and the camera, checks the capability register to see if logging functionality is supported. If not, the time synchronization phase is skipped; otherwise, time synchronization is performed. The host computer obtains the current timestamp, splits it, and stores it in the camera's high-order and low-order timestamp registers. It then calls DRV_slogSetUnixTime (Driver Serial Log Set UnixTime) to set the absolute time base and base count value, obtaining the current recording time. The camera calls the SLOG (Serial Log) macro interface, using a fixed 64-word structure (timestamp + string) to record the current log; it writes the current log to a memory circular buffer. The camera updates the header firstIndex / lastIndex and delays writing the current log to Flash. The camera calls DRV_slogFlushFlash(Driver Serial Log Flush Flash), which blocks and waits until all logs in the memory ring buffer are written to the Flash. After ensuring log integrity, the log writing process ends.

[0047] As can be seen, the "delayed write + periodic flush" mechanism is adopted, merging and writing the current log every second by default to avoid frequent operations; in emergency situations, DRV_slogFlushFlash can be used to force disk write. This optimizes the Flash write strategy and extends its lifespan.

[0048] The camera end includes a switch register. The step of the logging device writing the current log to the buffer through the driver layer includes: writing the current log to the buffer in response to detecting that the switch register is in the enabled state; and stopping writing the current log in response to detecting that the switch register is in the disabled state.

[0049] A switch register is a "virtual switch panel" inside a chip. By writing "0" or "1" to a specific register, a function or signal path on the hardware can be physically turned on or off.

[0050] In some embodiments, when the log export process begins, the logging device sets a switch register to trigger an export lock, closing the switch register and blocking new write operations to the current log, thus achieving read-write isolation between log export and writing. After log export is complete, the logging device clears the export switch register, releasing the export lock. At this point, the switch register is open, and the logging device can write the current log to the buffer through the driver layer, resuming normal log writing. This ensures that log data is not modified during the export process, guaranteeing the integrity and consistency of the exported data and avoiding data corruption caused by log updates during the export process.

[0051] As can be seen, by locking log writing through the switch register, new log writing is paused during the export process to prevent data tearing; the register is unlocked after the export is completed to ensure consistency.

[0052] The buffer includes a primary partition and a backup partition. After storing the current log in the buffer, the method further includes: in response to receiving a log recovery instruction, determining the target log from the backup partition based on the log to be recovered in the log recovery instruction; and writing the target log to the primary partition.

[0053] Log recovery commands are instructions used to recover the logs of the primary partition. Log recovery commands include the logs to be recovered. The logs to be recovered can include log recording timestamps, log events, etc.

[0054] In response to receiving a log recovery command, the logging device determines the corresponding target log from the backup partition based on the log recording time or event. The backup partition includes preset recording time, preset log events, and the correspondence between preset logs. The target log is then copied and written to the primary partition.

[0055] As can be seen, by adopting a primary and secondary Flash partition dual backup mechanism to synchronize the valid logs of the secondary partition to the primary partition, the log data is dually backed up and automatically recovered from the fault. If any partition is damaged, it can be recovered from the other partition, which greatly improves the robustness of log storage and avoids the problem of log loss caused by power outages and abnormal restarts. Thus, the log reliability and power outage resistance can be significantly improved.

[0056] This application provides a log acquisition method, which is applied to a host computer. For details, please refer to [link / reference needed]. Figure 3 , Figure 3 This is a flowchart illustrating an exemplary embodiment of a log acquisition method shown in this application.

[0057] Specifically, a log acquisition method includes the following steps: S310, In response to detecting a connection between the host computer and the camera, determine whether the camera has a logging function.

[0058] After the host computer establishes communication with the camera, the SDK reads the default values ​​from the camera's capability register. These default values ​​indicate whether the camera supports logging functionality. For example, a default value of the first threshold indicates that the camera supports logging functionality, while a default value of the second threshold indicates that the camera does not support logging functionality.

[0059] In one embodiment, the SDK reads the default value in the capability register of the camera. If the default value is a first threshold, it is determined that the camera supports the logging function. If the default value is a second threshold, it is determined that the camera does not support the logging function.

[0060] S320. If so, the current timestamp of the host computer is split and processed to obtain the time information.

[0061] In response to the camera's support for logging, the host computer splits the current timestamp (uint64_t, millisecond level) into two 32-bit high-order and low-order timestamps. It's important to note that the camera's register space uses a 32-bit basic access width, while the host computer provides a 64-bit unsigned integer in milliseconds, which is then split into two 32-bit time data units.

[0062] S330: Send time information to the camera.

[0063] The host computer sends 32-bit high-order time data and 32-bit low-order time data to the camera. The camera stores the 32-bit high-order time data in the high-order timestamp register and the 32-bit low-order timestamp data in the low-order timestamp register.

[0064] S340: Trigger the camera to respond upon receiving the time information sent by the host computer, and determine the current recording time of the camera based on the time information.

[0065] For detailed steps of step S340, please refer to step S110, which will not be repeated here.

[0066] S350. Record the log based on the current recording time to obtain the current log, which includes the current timestamp of the host computer.

[0067] For detailed steps of step S350, please refer to step S120, which will not be repeated here.

[0068] S360: Store the current log in the cache.

[0069] For detailed steps of step S360, please refer to step S130, which will not be repeated here.

[0070] In one embodiment, the host computer receives the "Export Log" command clicked on the interface and sends a log read instruction to the camera. The camera sets the switch register to 1 to lock log writing, and calls `DRV_slogExportDataBegin(DriverSerial Log Export Data Begin, Start of serial log export data)` to read the effective data length register `total_len` (Total Length) in the buffer, reading string type registers in a loop and partitioned manner, with a single read size ≤ 1MB. The camera then calls `DRV_slogExportData(Driver Serial Log ExportData, Drive serial log export data)`. `DRV_slogExportData` includes `buf` (buffer), `offset` (offset), and `site` (position). It checks if the reading is complete. If not, it returns to the step of reading string type registers in a loop and partitioned manner; otherwise, it sets the switch register to 0 and calls `DRV_slogExportDataEnd(Driver Serial Log ExportData End, End of serial log export data)`, ending the log reading process.

[0071] After the host computer sends the time information to the camera, the method further includes: in response to receiving a log read instruction, obtaining log information from the main partition of the camera; verifying the log information and obtaining a verification result; in response to the verification result indicating verification failure, obtaining log information from the backup partition of the camera and sending a log recovery instruction for the main partition to the camera.

[0072] A log read command is an instruction to read logs from the camera. Specifically, the host computer uses the input command to read the logs as the log read command. The log read command includes the logs to be read. The logs to be read may include the time to be read, the event to be read, etc.

[0073] After receiving the log read command, the host computer sends the command to the camera, triggering the camera to retrieve log information from the main partition based on the log to be read in the command, and then sends the log information back to the host computer. Specifically, the camera searches for the corresponding log information in the logs stored in the main partition based on the log time or log event to be read. The main partition stores the correspondence between preset log times, preset log events, and preset logs.

[0074] The host computer performs integrity verification on the log information and obtains the verification result. If the verification result indicates success, the host computer exports the log information obtained from the primary partition and displays it on the interface. If the verification result indicates failure, the host computer reads the log from the backup partition based on the log to be read in the log read command, obtains the log information, exports the log information from the backup partition, and displays it on the interface. The host computer sends a log recovery command for the primary partition to the camera, triggering the camera to respond to the received log recovery command. Based on the log to be recovered in the log recovery command, the camera determines the target log from the backup partition and writes the target log into the primary partition.

[0075] In one embodiment, integrity verification includes data incompleteness verification and checksum verification. If the log information obtained from the primary partition contains incomplete data or the checksum does not match, the verification result is determined to be verification failure; otherwise, the verification result is determined to be verification success. Thus, log header magic number verification ensures structural integrity and improves log reliability.

[0076] The host computer sorts the exported logs by time and displays them on the interface. The exported logs include the log recording time, such as "2025-11-18 09:01:02.123". Therefore, by arranging and displaying the exported logs, the host computer achieves automated management and display, which helps improve operational efficiency.

[0077] In one embodiment, the host computer obtains log information from the main partition of the camera. The log information includes a log header. The host computer verifies that the magic number in the log header is 0x12345678. If the magic number is 0x12345678, the verification is successful and the log information in the main partition is exported normally. Otherwise, the verification fails, the host computer obtains log information from the backup partition, and performs data recovery on the main partition based on the log information in the backup partition.

[0078] Figure 4 This is a block diagram illustrating a logging apparatus according to an exemplary embodiment of this application. Figure 4 As shown, the exemplary log recording device 400 includes: a first determining module 410, a first log recording module 420, and a first log storage module 430. Specifically: The first determining module 410 is used to determine the current recording time of the camera based on the time information received from the host computer.

[0079] The first log recording module 420 is used to record logs based on the current recording time to obtain the current log, which includes the current timestamp of the host computer.

[0080] The first log storage module 430 is used to store the current log in the cache area.

[0081] In this exemplary logging device, in response to receiving time information sent by the host computer, the current recording time of the camera is determined based on the time information; a log is recorded based on the current recording time to obtain the current log, which includes the current timestamp from the host computer; and the current log is stored in a buffer. Thus, by determining the current recording time of the camera based on the time information from the host computer, and thereby obtaining the current log containing the current timestamp from the host computer, the time consistency between the current log and the host computer is ensured, thereby improving the accuracy of the log recording time.

[0082] Figure 5 This is a block diagram illustrating a log acquisition apparatus according to an exemplary embodiment of this application. Figure 5 As shown, the exemplary log acquisition device 500 includes: a judgment module 510, a splitting module 520, a time sending module 530, a second determination module 540, a second log recording module 550, and a second log storage module 560.

[0083] The judgment module 510 is used to determine whether the camera has a logging function in response to the detection of a connection between the host computer and the camera.

[0084] The splitting module 520 is used to split the current timestamp of the host computer to obtain time information when the camera has a logging function.

[0085] The time transmission module 530 is used to send time information to the camera.

[0086] The second determining module 540 is used to trigger the camera to respond to the time information sent by the host computer and determine the current recording time of the camera based on the time information.

[0087] The second log recording module 550 is used to record logs based on the current recording time to obtain the current log, which includes the current timestamp of the host computer.

[0088] The second log storage module 560 is used to store the current log in the cache area.

[0089] The functions of each module can be found in the examples of the logging method and the logging acquisition method, and will not be repeated here.

[0090] To implement the log recording method and log acquisition method of the above embodiments, this application proposes another electronic device, please refer to [link / reference needed]. Figure 6 , Figure 6 This is a schematic diagram of the structure of an embodiment of the electronic device provided in this application.

[0091] Electronic device 600 includes memory 601 and processor 602, wherein memory 601 and processor 602 are coupled together.

[0092] The memory 601 is used to store program data, and the processor 602 is used to execute the program data to implement the log recording method and log acquisition method of the above embodiments.

[0093] In this embodiment, processor 602 can also be referred to as CPU (Central Processing Unit). Processor 602 may be an integrated circuit chip with signal processing capabilities. Processor 602 can also be a general-purpose processor, digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component. The general-purpose processor can be a microprocessor, or processor 602 can be any conventional processor.

[0094] This application also provides a computer-readable storage medium, such as Figure 7 As shown, the computer-readable storage medium 700 is used to store program data 701. When the program data 701 is executed by the processor, it is used to implement the log recording method and log acquisition method as described in the method embodiments of this application.

[0095] The methods involved in the log recording and log acquisition methods embodiments of this application, when implemented as software functional units and sold or used as independent products, can be stored in a device, such as a computer-readable storage medium. Based on this understanding, the technical solution of this application, essentially, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0096] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

[0097] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus. The term "and / or" is merely a description of the association of related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, and B alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, "many" in this document means two or more. In addition, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of elements, such as including at least one of A, B, and C, and may mean including any one or more elements selected from the set consisting of A, B, and C.

Claims

1. A log recording method, characterized in that, The logging method is applied to a camera, which includes a buffer and is connected to a host computer. The method includes: In response to receiving time information sent by the host computer, the current recording time of the camera is determined based on the time information; Based on the current recording time, a log is recorded to obtain the current log, which includes the current timestamp of the host computer; Store the current log in the cache area.

2. The method according to claim 1, characterized in that, The step of determining the current recording time of the camera based on the time information includes: The time information is processed by time merging to obtain the current timestamp of the host computer; The current recording time of the camera is determined based on the current timestamp of the host computer.

3. The method according to claim 1, characterized in that, The camera terminal includes an application layer and a driver layer. The step of storing the current log to the cache includes: The current log is sent to the driver layer through the macro interface of the application layer; The current log is written to the cache area through the driver layer.

4. The method according to claim 3, characterized in that, The cache area includes a primary partition and a backup partition. The step of writing the current log into the cache area through the driver layer includes: Determine the writing strategy for the current log; The current log is written to the primary partition and the backup partition respectively according to the writing strategy.

5. The method according to claim 3, characterized in that, The camera end includes a switch register, and the step of writing the current log to the buffer through the driver layer includes: In response to detecting that the startup state of the switch register is enabled, the current log is written to the buffer. In response to detecting that the start state of the switch register is the off state, writing to the current log is stopped.

6. The method according to claim 1, characterized in that, The cache area includes a primary partition and a backup partition. After the step of storing the current log in the cache area, the method further includes: In response to receiving a log recovery instruction, the target log is determined from the backup partition according to the log to be recovered in the log recovery instruction; Write the target log to the primary partition.

7. A log acquisition method, characterized in that, The log acquisition method is applied to a host computer, and the method includes: In response to detecting a connection between the host computer and the camera, determine whether the camera has a logging function; If so, the current timestamp of the host computer is split to obtain time information; The time information is sent to the camera, and the camera is triggered to respond to the time information sent by the host computer. The camera determines the current recording time based on the time information. The camera records a log based on the current recording time to obtain the current log, which includes the current timestamp of the host computer. The current log is stored in the cache.

8. The method according to claim 7, characterized in that, After the step of sending the time information to the camera, the method further includes: In response to receiving a log read command, log information is obtained from the main partition of the camera. The log information is verified to obtain the verification result; In response to the verification result indicating a verification failure, log information is obtained from the backup partition of the camera and a log recovery command for the primary partition is sent to the camera.

9. An electronic device, characterized in that, include: A memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to perform the method as claimed in any one of claims 1-8.

10. A computer-readable storage medium, characterized in that, include: The system stores program data, which, when executed by a processor, is used to implement the method as described in any one of claims 1-8.