OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Public API for the C and C++ bindings to the Chromium OS | 5 // Public API for the C and C++ bindings to the Chromium OS |
6 // 'bootstat' facility. The facility is a simple timestamp | 6 // 'bootstat' facility. The facility is a simple timestamp |
7 // mechanism to associate a named event with the time that it | 7 // mechanism to associate a named event with the time that it |
8 // occurred and with other relevant statistics. | 8 // occurred and with other relevant statistics. |
9 | 9 |
10 #ifndef BOOTSTAT_H_ | 10 #ifndef BOOTSTAT_H_ |
11 #define BOOTSTAT_H_ | 11 #define BOOTSTAT_H_ |
12 | 12 |
13 #if defined(__cplusplus) | 13 #if defined(__cplusplus) |
14 extern "C" { | 14 extern "C" { |
15 #endif | 15 #endif |
16 | 16 |
17 // | 17 // |
18 // Length of the longest valid string naming an event, including the | 18 // Length of the longest valid string naming an event, including the |
19 // terminating NUL character. Clients of bootstat_log() can use | 19 // terminating NUL character. Clients of bootstat_log() can use |
20 // this value for the size of buffers to hold event names; names | 20 // this value for the size of buffers to hold event names; names |
21 // that exceed this buffer size will be truncated. | 21 // that exceed this buffer size will be truncated. |
22 // | 22 // |
23 // This value is arbitrarily chosen, but see comments in | 23 // This value is arbitrarily chosen, but see comments in |
24 // bootstat_log.c regarding implementation assumptions for this | 24 // bootstat_log.c regarding implementation assumptions for this |
25 // value. | 25 // value. |
26 // | 26 // |
27 #define BOOTSTAT_MAX_EVENT_LEN 64 | 27 #define BOOTSTAT_MAX_EVENT_LEN 64 |
28 | 28 |
| 29 // bootstat_log() |
| 30 // |
29 // Log an event. Event names should be composed of characters drawn | 31 // Log an event. Event names should be composed of characters drawn |
30 // from this subset of 7-bit ASCII: Letters (upper- or lower-case), | 32 // from this subset of 7-bit ASCII: Letters (upper- or lower-case), |
31 // digits, dot ('.'), dash ('-'), and underscore ('_'). Case is | 33 // digits, dot ('.'), dash ('-'), and underscore ('_'). Case is |
32 // significant. Behavior in the presence of other characters is | 34 // significant. Behavior in the presence of other characters is |
33 // unspecified - Caveat Emptor! | 35 // unspecified - Caveat Emptor! |
34 // | 36 // |
35 // Applications are responsible for establishing higher-level naming | 37 // Applications are responsible for establishing higher-level naming |
36 // conventions to prevent name collisions. | 38 // conventions to prevent name collisions. |
37 extern void bootstat_log(const char* event_name); | 39 extern void bootstat_log(const char* event_name); |
38 | 40 |
| 41 // bootstat_set_output_directory() |
| 42 // |
| 43 // Change the default directory into which bootstat_log() writes |
| 44 // timestamp files. The input parameter is the directory path. |
| 45 // If the input parameter is NULL, the output directory is set |
| 46 // back to the initial default directory. |
| 47 // |
| 48 // bootstat_set_output_directory() checks its input path for |
| 49 // appropriate permissions when called. If permissions to the |
| 50 // selected output directory are subsequently lost, bootstat_log() |
| 51 // fails silently. The caller is responsible for selecting a |
| 52 // directory that is not subject to change. |
| 53 // |
| 54 // Returns 0 on success. On failure, returns -1, with errno set as |
| 55 // for the access(2) system call. |
| 56 extern int bootstat_set_output_directory(const char*); |
| 57 |
39 #if defined(__cplusplus) | 58 #if defined(__cplusplus) |
40 } | 59 } |
41 #endif | 60 #endif |
42 #endif // BOOTSTAT_H_ | 61 #endif // BOOTSTAT_H_ |
OLD | NEW |